我想更新和ArrayAdapter
a TextView
當用戶點擊+
或-
按鈕時。我無法弄清楚如何在ArrayApapter
中更改個人資料。
這裏是爲了更好地解釋圖像是我想做的事:如何在Android中單獨更新ArrayAdapter數據
public View getView(int position, View countView, ViewGroup parent) {
View listView = countView;
if (listView == null) {
listView = LayoutInflater.from(getContext()).inflate(R.layout.listview, parent, false);
}
word currentWord = getItem(position);
TextView foodName = (TextView) listView.findViewById(R.id.food);
Button minus = (Button) listView.findViewById(R.id.minus);
Button add = (Button) listView.findViewById(R.id.add);
TextView total = (TextView) listView.findViewById(R.id.total);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
minus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
return listView;
}
嘗試此鏈接http://stackoverflow.com/questions/3724874/how-can-i-update-a-single-row-in-a-listview –