I am developing an App for cricket. In that my aim is to select players for the particular team in ListView. Here I can able to select multiple players from the list. I am using simple Adapter with multiple choice Listview.
adapter=new ArrayAdapter<String>(this,R.layout.custom_list_view,R.id.textView_color,playersName);
lvview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
And I am using checkedTextView for multiple selection. Below is my custom_list_view with CheckedTextView
<CheckedTextView
android:id="@+id/textView_color"
android:layout_width="fill_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"
android:textColor="#FFffFF"
/>
And now my problem is I want to change the color of listview when user select the particular player from the list. Its like to show the user which players are selected. To Differentiate from the unselected player I am changing the color of selected player to red.
lvview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position,long id) {
// TODO Auto-generated method stub
SparseBooleanArray checked = lvview.getCheckedItemPositions();
if(checked.get(position))
{
//chkTextView.setTextColor(Color.GREEN);
counter_selected++;
selectedCounterText.setText("" + counter_selected);
}
else
{
counter_selected--;
selectedCounterText.setText("" + counter_selected);
}
}
});
How to change the color of selected player from default color to Red. I am struggling to do that.. Please help me to find it out..