我有一個ListView,我需要更新特定行的內容,而無需重新加載所有ListView內容。此ListView可以很大。更新Android中的行內容ListView
例如(爲了簡單起見)我需要更改位於適配器'x'位置的視圖(行)中的TextView(適配器中的label3)的內容。其實我使用TouchListView(Commonsware)適配器。
class IconicAdapter extends ArrayAdapter<FavoriteObject> {
IconicAdapter() {
super(FavoritesMainActivity.this, R.layout.favbusrow, array);
}
public View getView(int position, View convertView,ViewGroup parent) {
View row=convertView;
LayoutInflater inflater=getLayoutInflater();
ListFav lf = (listFav) array.get(position).getContent();
row=inflater.inflate(R.layout.favrow,parent, false);
row.setBackgroundColor(Color.WHITE);
TextView label=(TextView)row.findViewById(R.id.busNameF);
label.setText(lf.getName());
label.setTextColor(Color.BLACK);
label.setTypeface(FontsManager.getBoldFont());
TextView label2 =(TextView)row.findViewById(R.id.busNumberF);
label2.setText(lf.getNumber());
label2.setTextColor(Color.BLACK);
label2.setTypeface(FontsManager.getBoldFont());
TextView label3 =(TextView)row.findViewById(R.id.busDirectionF);
label3.setText(lf.getQuickName());
label3.setTextColor(Color.BLACK);
label3.setTypeface(FontsManager.getRegularFont());
return(row);
}
}
有人有想法嗎?
謝謝!
您確實沒有給出足夠的信息以獲得可靠的答案。名單很長嗎?你只更新這一個領域?你使用什麼樣的適配器? –
可以訪問一行的內容嗎? – Maxime