在該方法onItemClick()
獲取對應於位置(位置參數)的行點擊,更新該值,然後通知該數據已與呼叫改變到方法notifyDataSetChanged()
適配器中PhoneBook
元件:
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());
}
});
感謝您工作了很多 – Ha3Ha3Ha3 2012-03-25 09:20:04
我嘗試了很多例子,這對我很有用!!很棒的工作 – 2017-01-18 11:37:34