I have seen similar questions and tried the solutions such as setting focusable to false but it is still not working. Here is my layout that contains the listview:
after setting
android:focusable="false"
for your ListView content, in your ListView Tag Add
android:clickable="true"
Actually nothing is wrong.
But the problem is from the custom_list_row.xml
, when you click on the list view item,
You actually click on other tags in your
custom_list_row.xml
and these tags are not responsible for firing the ItemClickListener
.
Change value of property android:layout_width
of tags in the custom_list_row.xml
to "wrap_content"
or remove the tags and try again.
I too faced this issue, I overcome from this issue by setting click listener to convertView
of custom adapter
. I don't know is this good approach but it solved my issue.
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
KeepassDBGroupv1 rowItem = getItem(position);
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.custom_list_row, null);
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.textView_group_entry_name);
holder.imageView = (ImageView) convertView.findViewById(R.id.imgView_group_entry_icon);
holder.type = (TextView) convertView.findViewById(R.id.textView_group_entry_type);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
holder.name.setText(rowItem.getGroupName());
holder.type.setText("Group");
Drawable d = context.getResources().getDrawable(context.getResources().getIdentifier("ic"+Integer.toString(rowItem.getImageId()), "drawable", context.getPackageName()));
holder.imageView.setImageDrawable(d);
//App.getDB().drawFactory.assignDrawableTo(holder.imageView, context.getResources(), rowItem.icon);
convertView.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Log.v("OpenDbListAdapter ","List View Clicked");
}
});
return convertView;
}