Android GridView OnItemClickListener area -
i have gridview displays bunch of thumbnail images. looks good, when click on item, upper right hand portion of image register onitemclicklistener call. if click lower left hand corner, nothing happens. when fill gridview many images, clicking on images trigger call @ wrong position.
here relevant code adapter:
imageview = new imageview(mcontext); final float scale = getbasecontext().getresources().getdisplaymetrics().density; int pixels = (int) (155 * scale + 0.5f); imageview.setlayoutparams(new gridview.layoutparams(pixels, pixels)); imageview.setscaletype(imageview.scaletype.center_crop); imageview.setpadding(8, 8, 8, 8);
here listener code:
gridview gridview = (gridview) findviewbyid(r.id.gridview); gridview.setadapter(new imageadapter(this)); gridview.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view v, int position, long id) { intent intent = new intent(mobialgrid.this,mobialimageind.class); intent.putextra("image", file[position].getabsolutepath()); startactivity(intent); } });
here grid xml:
<gridview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:columnwidth="160dp" android:numcolumns="auto_fit" android:verticalspacing="10dp" android:horizontalspacing="10dp" android:stretchmode="columnwidth" android:gravity="center" android:paddingtop="15dp" android:paddingbottom="15dp" android:background="@drawable/dark_bg_repeat" />
thanks comments.
try add listener on imageviews in adapter, might help...
Comments
Post a Comment