Thus, I dealt with a similar problem, it is basically reinitializing the adapter, for example, as shown in the blindstuff file.
public class Example extends Activity{ CustomAdapter adapter; ArrayList<ArrayList<String>> info = new ArrayList<ArrayList<String>>(); final ListView list = (ListView) findViewById(R.id.listView_custom); adapter = new CustomAdapter(this, diceInfo.get(id)); list.setAdapter(adapter);
Then in the onclick Listener
add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { info.get(id).add("1,0,0,true"); adapter = new CustomAdapter(Example.this, info.get(id)); list.setAdapter(adapter); } });
The example does not have everything initialized, but it comes to the point. I just create a new adapter and install it in the list that I have. It works well.
source share