This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Android and the fly likes Update the List View at run time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Update the List View at run time" Watch "Update the List View at run time" New topic
Author

Update the List View at run time

Apt Gopal
Greenhorn

Joined: Dec 07, 2010
Posts: 25
Hi

I am creating a new android application in that app I want add the list content from the Edit text

That means I have a Edit text field,Button,List View I write some thing in edit text and at the time of button clicking I want to add the content in the list view

Please any one help me

Thanks in Advance
Misha van Tol
Ranch Hand

Joined: Jan 02, 2010
Posts: 56

Let us see what code you have so far, or show some pseudo-code of what you have in mind.
Then we can discuss it here.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Wow, I am just now doing this same thing. Here is what I did:

1) In the layout XML file, I included a ListView with the id "@android:id/list"
2) I create an activity class that extended ListActivity (which automatically handles the ListView declared in the layout file)
3) I created an adapter class that extended ArrayAdapter, and hooked that to the activity (the adapter maintains the list contents)
4) When I got the input from the EditText field, I used Adaptor.add() to add the new entry to the list.


JBoss In Action
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

See API Demos - using List in transcript mode. Similar to what PJ outlined.


[List of FAQs] | [Android FAQ] | [Samuh Varta]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Update the List View at run time
 
Similar Threads
Creating custom views for Image Views
use the default db
Multiple Button
Adding item to listview dynamically........
Portlet modes