Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7714393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:06:58+00:00 2026-06-01T02:06:58+00:00

In ma application I am using a gallery widget having an ImageView and a

  • 0

In ma application I am using a gallery widget having an ImageView and a button. I am able to get the Imageview click on gallery.setOnItemClickListener event, but I am not getting ma button click . how can I get the button click. Please help me.

Please look into ma code:

public ImageAdapter(Activity c,Integer[] images) {
        this.mContext = c;
        this.Images=images;
        TypedArray attr = mContext.obtainStyledAttributes(R.styleable.HelloGal999lery);
        mGalleryItemBackground = attr.getResourceId(
                R.styleable.HelloGal999lery_android_galleryItemBackground, 0);
        attr.recycle();
    }

    public int getCount() {
        return Images.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return 1;
    }

    public boolean onInterceptTouchEvent(MotionEvent __e) {
        return false;
    }


     static class ViewHolder{
        public ImageView imageView1;
        public ImageButton btn1;
     }

    public View getView(int position, View convertView, ViewGroup parent) {  

         ViewHolder holder; 
         View rowView = convertView;

        if(rowView==null)
        {
         LayoutInflater inflater = mContext.getLayoutInflater();
         rowView = inflater.inflate(R.layout.test, null, true);
         holder=new ViewHolder();
         holder.imageView1=(ImageView) rowView.findViewById(R.id.ImageViewuser);    
         holder.btn1=(ImageButton)rowView.findViewById(R.id.Download);
         holder.imageView1.setImageResource(Images[position]);               
         holder.imageView1.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
         holder.imageView1.setBackgroundResource(mGalleryItemBackground);                
        }
        // rowView.setMinimumHeight(100);
         return rowView;                    
    }

Ma parent layout

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"    
     >  


            <Gallery  
        android:id="@+id/gallery"
        android:layout_width="fill_parent"
        android:spacing="10dp"            
        android:layout_height="fill_parent" />



</RelativeLayout> 

Ma child layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical" >

   <ImageView 
       android:id="@+id/ImageViewuser"
       android:layout_width="150dip"
       android:layout_height="150dip"         

       />
<ImageButton 
    android:id="@+id/Download"
    android:layout_below="@+id/ImageViewuser"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"    
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="50dp"    
    android:background="@drawable/clearall1"
    />

</RelativeLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:06:59+00:00Added an answer on June 1, 2026 at 2:06 am

    you did’t wrote code for click events, add onClick() function for button in the getView() method

    holder.btn1=(ImageButton)rowView.findViewById(R.id.Download);     
    btn1.setOnClickListener(new View.OnClickListener() {
       public void onClick(View v) {
         ///  write code here  
       }     
    }); 
    

    you can get position here

    and also
    you can get position like this
    position of the item in gallery

    gallery.setOnItemClickListener(new OnItemClickListener() {
       public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
          Toast.makeText(GalleryActivity.this, "" + position, Toast.LENGTH_SHORT).show();
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an application that shows a lot of images (currently using Gallery, but
I am trying to develop an image gallery application using Qt Framework. The application
I'm using CakePHP to build an application using the MVC Pattern, but my question
I have made an application using Java/Hibernate/MySQL, but whenever I try running it, it
I am using a gallery layout in my application. It is working when the
I have an application with a UITabBar. I have implemented a Photo Gallery using
Well, in my application I'm using default camera and gallery of Android with startActivityforResult
I'm developing an application to display a gallery of UIImages by using a UIScrollView
In My Android Camera Application, I am using this code to get Select Image
I have created a photo gallery application using Three20 framework. It works fine with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.