Wednesday, November 27, 2013

BINDING DATA TO LISTVIEW IN ANDROID USING VS2012

MoNoDROID– BINDING DATA TO LISTVIEW IN ANDROID using vs2012

 
 
 
 
 
 
Rate This

In the previous post, we used a ListActivity for displaying data or collection. In this post we would use theListView control and bind data or collection to it.
We would need a template for the ListView, so let’s add one.

Add an XML file to the Layout folder.


Add a TextView in the XML file. This is for ListView template.

And as you see in the below image, the Activity1 is inherited from Activity class unlike our last post where we inherited from ListActivity. Rest of the code is self-explanatory. We are setting the Adapter property of the ListView with ArrayAdapter.

Now, let’s run the application and see the ListActivity in action

As you see, unlike ListActivity, we have other controls in the Activity.
Hope this post helps, thanks for reading.

No comments:

Post a Comment