Вы можете расширить SimpleAdapter
следующим образом:
private class MyAdapter extends SimpleAdapter {
public MyAdapter(Context context, List<? extends Map<String, ?>> data,
int resource, String[] from, int[] to) {
super(context, data, resource, from, to);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
v.setBackgroundColor(Color.BLACK); //or whatever is your default color
//if the position exists in that list the you must set the background to BLUE
if(pos!=null){
if (pos.contains(position)) {
v.setBackgroundColor(Color.BLUE);
}
}
return v;
}
}
Затем в своей деятельности добавьте поле, подобное этому:
//this will hold the cliked position of the ListView
ArrayList<Integer> pos = new ArrayList<Integer>();
и установите адаптер:
sa = new MyAdapter(
getApplicationContext(),
expsList,
R.layout.listelement,
new String[] { "screen_name","text" },
new int[] { R.id.Name, R.id.Value}) {
};
m_listFile.setAdapter(sa);
При нажатии на строку:
public void onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
// check before we add the position to the list of clicked positions if it isn't already set
if (!pos.contains(position)) {
pos.add(position); //add the position of the clicked row
}
sa.notifyDataSetChanged(); //notify the adapter of the change
}