Android - Gridview Onitemclick
Hi i have strange problem with my gridView. I set on this itemClikListener and it doesn't work. Structure of view is this: GridView -> LinearView with ImageView. When i set item
Solution 1:
One problem in you code is missing @Override annotation.
board.setOnItemClickListener(newAdapterView.OnItemClickListener() {
@OverridepublicvoidonItemClick(AdapterView<?> parent, View v, int position, long id) {
Log.d("CLICK", "onClick");
}
});
If still that doesn't works. Then may be any of your Grid Item's child view is also listening for click event. If you know about the even handling procedure of android Touch Framework then you probably understand my point. Else It will be very good to know how android Touch Framework works. You can Learn about that here.
Solution 2:
@Override
annotation is missing for implemented method. Also anonymous inner class should refer from AdapterView. Please see below sample code.
board.setOnItemClickListener(newAdapterView.OnItemClickListener() {
@OverridepublicvoidonItemClick(AdapterView<?> parent, View v, int position, long id) {
Log.d("CLICK", "onClick");
}
});
Solution 3:
Try to add these to your GridView
Items'slayout.xml
android:focusable="false"android:focusableInTouchMode="false"
Also make sure that your Adapter returns true
for the method
isEnabled(int position)
Post a Comment for "Android - Gridview Onitemclick"