Skip to content Skip to sidebar Skip to footer

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 ti

Solution 1:

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.

Post a Comment for "Android - Add Items To List View Programmatically"