i am doing a ListView with SimpleAdapter.. i am trying to set textcolour based on the data passed.
in the main activity:
ArrayList<HashMap<String, Object>> data=new ArrayList<HashMap<String,Object>>();
for(int i=0;i<Db.risposteDate.size();i++){
Esame e = Db.risposteDate.get(i);
HashMap<String,Object> EsamiMap=new HashMap<String, Object>();
EsamiMap.put("num", e.getDomandaNum());
EsamiMap.put("testo", Html.fromHtml(e.getTesto()+"<br />"));
EsamiMap.put("ris", e.getRispostaData());
data.add(EsamiMap);
}
String[] from={"num","testo","ris"}; //dai valori contenuti in queste chiavi
int[] to={R.id.tv1,R.id.tv2,R.id.tv3};//agli id delle view
//costruzione dell adapter
customAdapter adapter=new customAdapter(
getApplicationContext(),
data,
R.layout.riga_lista,
from,
to);
((ListView)findViewById(R.id.tabellaRisultati)).setAdapter(adapter);
i created a customAdapter:
class customAdapter extends SimpleAdapter {
public customAdapter(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 view = super.getView(position, convertView, parent);
return view;
}
}
but i have no idea how work getView()... i want that i read a value inside data and if is correct i want textcolour RED.
the main problem is that i don't know how "look" inside data.
I answered to a similar question a few days before. See my custom adapter, there is a getView method inside.
If you have questiosn, feel free to ask.
Here is the link: https://stackoverflow.com/questions/12525785/how-to-use-custom-list-adapter-for-android