1
  String[] mListContent={"Sunday", "Monday", "Tuesday", "Wedneday", "Thursday", "Friday", "Saturday"};
  setListAdapter( new AlarmDaysAdapter(this, android.R.layout.simple_list_item_checked, mListContent));
  ListView listView = getListView();
  listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);      
  for(ii=0; ii<values.size(); ii++)
  {
      listView.setItemChecked(values.get(ii),true);
      Log.i(" values: " + values.get(ii)," ");
  }

I want to check some list items while displaying the Listview. The Log.i prints the perfect values present in values.get(ii) that is the positions which I wanted to be checked by default. How can I achieve it?

Triode
  • 11,309
  • 2
  • 38
  • 48
AnRu
  • 67
  • 8
  • it has positions of the listview which should be checked or selected by default – AnRu Mar 15 '13 at 11:09
  • what's AlarmDaysAdapter ? – njzk2 Mar 15 '13 at 12:08
  • public class AlarmDaysAdapter extends ArrayAdapter { String[] days; ListlistDays; TasksDataSource datasource; @SuppressWarnings("unchecked") public AlarmDaysAdapter(Context context, int layout, String[] mListContent) { super(context, layout, mListContent); listDays = Arrays.asList(mListContent); } @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); return view; } – AnRu Mar 18 '13 at 05:49
  • I don't see the point of AlarmDaysAdapter. why not use a plain ArrayAdapter ? – njzk2 Mar 18 '13 at 08:39
  • yes.. I did have a plain array adapter. but included AlarmDaysAdapter so it may be used to check the individual rows!! – AnRu Mar 18 '13 at 08:53
  • still don't see. it is the listview that handles the checked states – njzk2 Mar 18 '13 at 08:59
  • ok. by using arrayadapter how can I check the row by default? – AnRu Mar 18 '13 at 09:33
  • i'd say just the same way you are doing. see this question http://stackoverflow.com/questions/5146182/android-listview-choice-mode-multiple-how-to-set-checked-index – njzk2 Mar 18 '13 at 10:21

0 Answers0