Note that there are some explanatory texts on larger screens.

plurals
  1. POGallery not getting button click
    text
    copied!<p>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.</p> <p>Please look into ma code:</p> <pre><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; } </code></pre> <p><strong>Ma parent layout</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;Gallery android:id="@+id/gallery" android:layout_width="fill_parent" android:spacing="10dp" android:layout_height="fill_parent" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p><strong>Ma child layout</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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" &gt; &lt;ImageView android:id="@+id/ImageViewuser" android:layout_width="150dip" android:layout_height="150dip" /&gt; &lt;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" /&gt; &lt;/RelativeLayout&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload