To fire an event when a button or list item is clicked, you can do the following:
You only process onItemClick:
mListView.setOnItemClickListener(new ListView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int i, long l) {
In the adapter, you change the button so that it cannot be clicked / focused (or do it in an XML file):
public class MyAdapter extends BaseAdapter { ... public View getView(int position, View convertView, ViewGroup parent) { ..... Button btn = view.findViewById(R.id.button); btn.setFocusable(false); btn.setClickable(false); } }
beta Sep 26 2018-12-12T00: 00Z
source share