MessageHi Eric,

    The documentation including the books, is so frustrating in the lack of 
help and explanation at times. What you need to do is insert and delete your 
items into the holder of your data and then display it in the listview. This 
might be an array, or as in my case a table in an SQLite database. I use a 
simplecursoradapter and call a cursor of all items and link this to the listview

myCursor = myAdapter.getAllItemsCursor(); 

String[] fromColumns = new String[] { myAdapter.field1, myAdapter.field2, 
myAdapter.KEY_ID };

int[] toMyLayout = new int[] { R.id.f1, R.id.f2, R.id.id_store };


final SimpleCursorAdapter   mySimpleCursorAdapter = new 
SimpleCursorAdapter(this, R.layout.mylayout, myCursor, fromColumns, toMyLayout);

myListView.setAdapter(mySimpleCursorAdapter );



Field1 is displayed in f1 and field2  in f2. I was putting KEY_ID into id_store 
hoping to retrieve it and use it in deleting an item later as required, but I 
cannot retrieve the text of the textview for the item that has been selected in 
the listview.  So I set up an array of ids with the index of the array being 
the same as the position of the item in the listview.

Then you can add an item to the database table and delete an item from the 
database table and update the listview to show the current contents.

Good luck and I hope that this has been of some help



Mike


--- Original Message ----- 
  From: Eric Belen 
  To: android-beginners@googlegroups.com 
  Sent: Saturday, August 15, 2009 3:19 AM
  Subject: [android-beginners] How To Delete An Item In ListView


  How do you insert a single item to a list view?
  and how to delete an item In ListView


  Eric Belen


  

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to