It works the same way as the onClickListener
, just instead you're checking the onLongClickListener
. So you'd have this kind of structure:
your_view.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
...
}
});
If you want to display a check mark, in my opinion the best way is defining your own row layout, where you just define a CheckBox
at the right side the content of the row. This way, instead of passing the ArrayAdapter
some Android layout, you'd specify your new layout, something like:
your_adapter = new ArrayAdapter(context, R.layout.your_new_layout, initial_rows);