1
   List<Integer> values;
   String[] mListContent={"Sunday", "Monday", "Tuesday", "Wedneday", "Thursday", "Friday", "Saturday"};
   Intent myIntent = getIntent();
   iid = myIntent.getExtras().getLong("curr_id");
   values = datasource.getDays(iid);
   ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.simple_selectable_list_item, mListContent); 
   setListAdapter(adapter);
   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 have a file named textcolorselector.xml for list, that goes

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#000" />
<item android:state_checked="true" android:color="#000" />
<item android:state_active="true" android:color="#000" />
<item android:state_selected="true" android:color="#000" />
<item android:color="#888" />   
</selector>

say like i have 7 defaut rows in my list and wanna highlight only certain positions

the values from the database are retreived perfectly,in the database i have saved only the position values of the list ie 0,1,...6 for sunday, monday,...saturday respectively, the problem is extracting values of "values" list is not being changed as set.

4

1 回答 1

1

您设置选择器的事实并不意味着它将用于“检查”项目。甚至更多 - 选择器与检查状态无关。

您需要做的是提供您自己的视图来ArrayAdapter实现Checkable状态并为其提供自己的可绘制对象。

于 2013-03-14T07:34:59.887 回答