我无法更改我的列表视图项目的背景颜色。
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.info_layout);
ListView listView;
listView = (ListView) findViewById(R.id.infolistView);
final String[] values = new String[] { "TO1", "TO2", "TO3" };
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
android.R.id.text1,
values);
listView.setAdapter(adapter);
// This is not make anything , why ?
View vi=adapter.getView(0, null, null);
vi.setBackgroundColor(Color.YELLOW);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//But here is running good
view.setBackgroundColor(Color.RED);}
});