Android - Add item to custom listview on button click

后端 未结 2 536
暗喜
暗喜 2021-01-20 00:57

I currently have a custom listview where each item on the list contains two rows of text. What I would like to do is each time a user clicks on the button, it creates a new

相关标签:
2条回答
  • 2021-01-20 01:30

    After calling fillData(), just make a call on adapter.notifyDataSetChanged().

    NotifyDataSetChanged() - Notifies the attached View that the underlying data has been changed and it should refresh itself.

    0 讨论(0)
  • 2021-01-20 01:33

    It's as simple as adding a new element to your ArrayList (like you do in fillData), then calling adapter.notifyDataSetChanged().

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