How do you dynamically add elements to a ListView on Android?

后端 未结 7 2046
情歌与酒
情歌与酒 2020-11-22 08:47

Can anyone explain or suggest a tutorial to dynamically create a ListView in android?

Here are my requirements:

  • I should be able to dynamically add new e
7条回答
  •  旧时难觅i
    2020-11-22 09:41

    instead of

    listItems.add("New Item");
    adapter.notifyDataSetChanged();
    

    you can directly call

    adapter.add("New Item");
    

提交回复
热议问题