这里我在ListView中为值设置了行的颜色。现在我想只设置这个字符串的颜色,没有所有行
ListAdapter adapter = new SimpleAdapter(MainActivity.this, DevicesList,
R.layout.list_item, new String[]{"name", "clients", "stan"},
new int[]{R.id.name, R.id.clients, enabled}){
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView v = (TextView) view.findViewById(R.id.enabled);
String a = v.getText().toString();
if (a == "Aktywny") {
view.setBackgroundColor(Color.argb(125,53,104,45));
} else if(a == "Nieaktywny") {
view.setBackgroundColor(Color.argb(125,175,43,30));
} else{
view.setBackgroundColor(Color.argb(125,139,140,122));
}
return view;
}
};
答案 0 :(得分:0)
v.setTextColor(Color.argb(125,175,43,30))