【发布时间】:2017-07-03 03:37:09
【问题描述】:
我有一个列表视图,我想在 onCreate 设置第一项的背景颜色。我试过这个:
mDrawerList = (ListView) findViewById(R.id.navList);
DrawerListAdapter adapter = new DrawerListAdapter(this, mNavItems);
mDrawerList.setAdapter(adapter);
View view = mDrawerList.getChildAt(1);
view.setBackgroundColor((parseColor("#008CC3")));
但它给出了 NPE。我该怎么做?
【问题讨论】:
标签: android listview background listviewitem