开发者

Android - add items to list view programmatically

I'm trying to create a to do list in android, where each item is a checkbox. I want to be able to programmatically update the list of items as the user (me) adds a new task. Any tips for how I could accomp开发者_开发知识库lish this?


As suggested notepad tutorial would be good here is a few design tips:

  1. You probably need to create layout with listview
  2. Then create another layout for your list rows to inflate which is in your case checkbox
  3. Create adapter for listview to set items by extending ArrayAdapter.
  4. Implement getView method and constructor of adapter class
  5. If user add something to list notify adapter that data set has changed and update ui accordingly

Note : do not update UI from background thread just use UI thread for this

Note 2 : In lists android have row recycle so when list expend the screen width check if checkboxes hold their states.

Hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜