Android's ArrayAdapter - add strings listview instead of replace

前端 未结 1 410
日久生厌
日久生厌 2020-12-20 12:42

This is how I add an array to listview:

ListView my_listview = (ListView)findViewById(R.id.listView1);
ArrayAdapter adapter = new ArrayAdapter&         


        
相关标签:
1条回答
  • 2020-12-20 13:07

    You need to be using an ArrayList<String> my_array rather than a String[] my_array and then you can do:

    my_array.addAll(other_array);
    

    to add elements from a new array to your array. Then you can do:

    adapter.notifyDataSetChanged();
    

    to update your ListView with the new elements.

    0 讨论(0)
提交回复
热议问题