我想替換ListItem
onItemClick
的視圖。然而,我所遇到的問題,重繪我這樣做的時候:在ListView中選擇更改ListItem視圖
public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
hlistAdapter.selected = position;
}
然後在適配器:
public View getView (int position, View convertView, ViewGroup parent) {
View retval;
if (position == selected)
retval = LayoutInflater.from(parent.getContext()).inflate(R.layout.new_list_item_selected, null);
else
retval = LayoutInflater.from(parent.getContext()).inflate(R.layout.new_list_item, null);
TextView title = (TextView) retval.findViewById (R.id.location);
title.setText (dataObjects[position]);
return retval;
}
我應該怎麼辦呢?