I have a customized ListView like this:
List<Journal_Database> values = localDatabase.getAllJournalNames();
ListView journalNames = (ListView)findViewById(R.id.JournalList);
journalNames.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
journalNames.setAdapter(new ArrayAdapter<Journal_Database>(
this,R.layout.journal_name_list_black_text,R.id.list_content, values));
How could I set the CHOICE_MODE_MULTIPLE ?
I tried this:
journalNames.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
But nothing happens.
EDIT :
I have found the solution, you can copy the choice_mode_multiple.xml file from the SDK folder to your project and change it.
I have this now:
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:textColor="#000000"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:paddingLeft="6dip"
android:paddingRight="6dip"
/>
And in the java code:
List<Journal_Database> values = localDatabase.getAllJournalNames();
ListView journalNames = (ListView)findViewById(R.id.JournalList);
journalNames.setAdapter(new ArrayAdapter<Journal_Database>(
this,R.layout.simple_list_item_multiple_choice,android.R.id.text1, values));
journalNames.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
Thank You
Look at this link.it may be Helpfull… http://www.vogella.de/articles/AndroidListView/article.html
Some Example like this…