【问题标题】:Change a TextView value in a custom ListView更改自定义 ListView 中的 TextView 值
【发布时间】:2012-03-25 08:36:57
【问题描述】:
【问题讨论】:
标签:
android
listview
android-listview
listadapter
【解决方案1】:
在onItemClick()方法中获取点击行的位置(位置参数)对应的PhoneBook元素,更新值,然后通过调用@987654323方法通知适配器数据发生了变化@:
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long index) {
// make the adapter a field in your class (or final)
PhoneBook element = (PhoneBook) adapter.getItem(position);
//modify the PhoneBook element
element.setPhone("555-555-555");
// notify the adapter that something has changed
adapter.notifyDataSetChanged();
showToast(listOfPhonebook.get(position).getName());
}
});