Can't Click On Items In Listview With Custom Adapter
I am trying to write an application which takes items from a database and populates rows within a ListView. I can't click on the items after tapping on the rows and the dpad won't
Solution 1:
Usually this happens because the items in your listview are in focus. Try adding
android:descendantFocusability="blocksDescendants"
in your custom listview row
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="?android:attr/listPreferredItemHeight"android:padding="6dip"android:orientation="vertical"android:descendantFocusability="blocksDescendants">
Solution 2:
I usually put the click listener in the adapter itself:
@Overridepublic View getView(int position, View convertView, ViewGroup parent) {
OnClickListeneryourClickListener=newOnClickListener() {
publicvoidonClick(View v) {
//put your desired action here
v.callOnClick();
}
};
...
// then add the listener to your view
tweetView.setOnClickListener(yourClickListener);
Solution 3:
add inside onItemClick method:
v.setSelected(true);
Solution 4:
Add the line below to your ListView xml
android:choiceMode="singleChoice"
Solution 5:
Tried this?
@OverridepublicbooleanisEnabled(int position) {
//Set a Toast or Log over here to check.returntrue;
}
Post a Comment for "Can't Click On Items In Listview With Custom Adapter"