的顏色。如何填寫我想設置選擇item.I已經設置列表視圖項和顏色像列表視圖中顏色的選擇列表項
{
setListAdapter(new ArrayAdapter<String>(getActivity(),
R.layout.simple_list_item_checkable_1, android.R.id.text1,Data.PERSON));
ListView listView = getListView();
listView.setTextFilterEnabled(true);
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
View listItem = parent.getChildAt(i);
if (listItem != null)
parent.setBackgroundColor(0x00000000);
view.setBackgroundColor(Color.RED);
}
});
}
是什麼錯誤?你的代碼的效果是什麼? –
你不會說會發生什麼。 view.setBackgroundColor(Color.RED);應該這是listItem.setBackgroundColor? – Simon
您可以[見這裏](http://samir-mangroliya.blogspot.in/p/android-customized-listview.html) –