Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>check this code: for single choice:</p> <pre><code> SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_single_choice, db.getAllTitles(), new String[] { "title" }, new int[] { android.R.id.text1 }); ListView listView = (ListView) findViewById(R.id.list); listView.setAdapter(adapter); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); </code></pre> <p>for multiple:</p> <pre><code>SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, simple_list_item_multiple_choice, db.getAllTitles(), new String[] { "title" }, new int[] { android.R.id.text1 }); ListView listView = (ListView) findViewById(R.id.list); listView.setAdapter(adapter); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); </code></pre> <p>depend on your requirement you have to set one of above: i think you aleady kno which question require single ans &amp; which require multiple depend on that you have to also create list item click like</p> <pre><code>listView.setOnItemClickListener(new OnItemClickListener() { private String my_sel_items; public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { if(ans == multiple){ my_sel_items = new String("Selected Items"); SparseBooleanArray a = lView.getCheckedItemPositions(); for (int i = 0; i &lt; a.size(); i++) { if (a.valueAt(i)) { my_sel_items = my_sel_items + "," + (String) listView.getAdapter().getItem(i); } } Log.v("values", my_sel_items); }else{ // for single it default selected item } } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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