implemented the code from this example: https://stackoverflow.com/questions/30711517/how-to-change-the-contents-of-listview-on-item-click/30711959#30711959

it is assumed that by clicking on the list, the string in it is replaced with the specified

when you click on the listView line, the item in the ItemAdapter updated, and the listView remains the same

How to make ListView update after ItemAdapter update?

added

Activity class:

 public class ItemActivity extends Activity { private ListView listView; private ItemAdapter itemListAdapter; private List<Item> itemList = new ArrayList<Item>(); @Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.list); listView = (ListView) findViewById(R.id.listView); itemListAdapter = new ItemAdapter(itemList, this); listView.setAdapter(itemListAdapter); listView.setFastScrollEnabled(true); //////////////////////////////////////////////// // add some items itemList.add(new Item("Charlie")); itemList.add(new Item("Jenny")); //add new items and changes to adapter itemListAdapter.notifyDataSetChanged(); //////////////////////////////////////////////// listView.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id){ String beforeName = itemListAdapter.getItem(position).getItemName().toString(); String changedName = "Thomas"; itemListAdapter.getItem(position).setItemName(changedName); } }); } } 

so earned:

 public void onItemClick(AdapterView<?> parent, View view, int position, long id){ String beforeName = itemListAdapter.getItem(position).getItemName().toString(); String changedName = "Thomas"; itemListAdapter.getItem(position).setItemName(changedName); itemListAdapter.notifyDataSetChanged(); } 

but do not want:

 itemListAdapter = new ItemAdapter(itemList, this); itemListAdapter.setNotifyOnChange(true); listView.setAdapter(itemListAdapter); 
  • show the code. adapter.notifyDataSetChanged () should update your sheet - Android Android
  • @AndroidAndroid, added a question - ravend

0