Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to find out if item is selected in CHOICE_MODE_MULTIPLE_MODAL inside custom ArrayAdapter?
    primarykey
    data
    text
    <p>Here is my problem: I have a ListView with a custom ArrayAdapter:</p> <p>My list in <code>onCreate()</code>:</p> <pre><code>list = /*some list*/ listView = (ListView) findViewById(R.id.some_list); listView.setAdapter(new MapListAdapter(this, R.layout.custom_list_item, list)); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { listView.setItemChecked(position, true); } }); mapListView.setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override public boolean onPrepareActionMode(...) { // some unrelated working code } @Override public void onDestroyActionMode(...) { // some unrelated working code } @Override public boolean onCreateActionMode(...) { // some unrelated working code } @Override public boolean onActionItemClicked(...) { // some unrelated working code } @Override public void onItemCheckedStateChanged(...) { // some unrelated working code } }); </code></pre> <p>My custom ArrayAdapter's <code>getView(...)</code>:</p> <pre><code>@Override public View getView (int position, View view, ViewGroup parent) { view = (LinearLayout) inflater.inflate(layoutId, null); final ListItem entry = getItem(position); // setting some textviews here and so on... CheckBox checkBox = (CheckBox) view.findViewById(R.id.m_l_i_checkbox); // my problem ^ return view; } </code></pre> <p>I know that certain list items are selected, because ActionMode bar appears as I select them and disappears as I unselect(toggle) all of them. However, I want to have checkBox that would indicate if they indeed are selected. So how do I do that? It works just fine with android.R.single_list_item_multiple_choice and default ArrayAdapter, but I want to use my custom one. Maybe I'm getting something wrong and there is another way to do it?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload