Listview Onitemclick Listener Is Not Working
I am working in an Android app where I need to create onItemClick method,but I fail to do so. Below is the code where the onItemClick method does not work. Does anyone have idea wh
Solution 1:
You are not setting your layout in your activity. First set your xml using setContentView() like this:
setContentView(R.layout.your_xml);
Then continue
mListview = (ListView) findViewById(R.id.mLiveview);
Solution 2:
Solution 3:
Try this in your ListView
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal"
android:scrollbars="vertical"
android:smoothScrollbar="true" />
If you are using custom ListView
, such as using a check box, use
android:focusable="false"
android:focusableInTouchMode="false"
<CheckBox
android:id="@+id/chk_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:focusable="false"
android:focusableInTouchMode="false" />
Solution 4:
The main thing you are forgetting is
setContentView(R.layout.activity_menus);
Post a Comment for "Listview Onitemclick Listener Is Not Working"