Currently, I have a ListView
row. Clicking any area on the row, will yield ListView
click events.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
this.getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
this.getListView().setMultiChoiceModeListener(new ModeCallback());
this.getListView().setOnItemClickListener(new ListViewOnItemClickListener());
} else {
// https://mcmap.net/q/383564/-listview-selection-remains-persistent-after-exiting-choice-mode
this.getListView().setOnItemLongClickListener(new ListViewOnItemLongClickListener());
this.getListView().setOnItemClickListener(new ListViewOnItemClickListener());
}
Now, for each row, I would like to add a small button. Clicking on the small button will yield button click event, which is different from ListView
original click event.
In my ArrayAdapter
, I use to have
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
if (rowView == null) {
LayoutInflater inflater = activity.getLayoutInflater();
rowView = inflater.inflate(R.layout.watchlist_row_layout, null);
...
}
Button button = (Button)rowView.findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Utils.showLongToast("BUTTON CLICK");
}
});
Clicking on the button will yield button click event. However, clicking on area other than button, will not yield any ListView
click event anymore.
May I know why is it so? Is there any way to resolve this?