Android 如何将getview()与AsyncTask中的SimpleAdapter一起使用?
我正在使用SimpleAdapter生成一个列表视图,如下所示:Android 如何将getview()与AsyncTask中的SimpleAdapter一起使用?,android,listview,simpleadapter,Android,Listview,Simpleadapter,我正在使用SimpleAdapter生成一个列表视图,如下所示: adapter = new SimpleAdapter(TodayActivity.this, detailslist, R.layout.singlerow, new String[] {"name","cname","cid","pid"}, new int[] { R.id.textView2,R.id.textView3,R.id.clid,R.id.projectid}){ public Vie
adapter = new SimpleAdapter(TodayActivity.this, detailslist,
R.layout.singlerow, new String[] {"name","cname","cid","pid"},
new int[] { R.id.textView2,R.id.textView3,R.id.clid,R.id.projectid}){
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
if(details.containsValue("12")){
//here if that value exits in hashmap
//I need to change a colour for that item position.
}
return v;
}
};
MyHashmap
HashMap<String, String> details = new HashMap<String, String>();
// adding each child node to HashMap key => value
details.put("name", "Project Name: "+Name);
details.put("cname", client_name);
details.put("cid", client_id);
details.put("pid", project_id);
details.put("flag", "False");
在这里,我需要为特定值设置一个条件,该值是否存在于hashmap中,如果该值存在,我需要为该项位置更改颜色。我试过了,它不起作用。我该怎么做?任何帮助都是值得的。在getView中尝试此代码
v.setBackgroundColor(youCondition? 0x9934B5E4: Color.TRANSPARENT);
return v;
我已经试过你的答案了。挫折背景颜色细节。包含价值12?0x9934B5E4:Color.TRANSPARENT;所有物品对我们都是透明的。