Search Wikipedia

Search results

Oct 15, 2013

Using only XML file for Listview control

List Controls by using only XML 

Most of the app provides the facility of browsing items in list.So, it is definitely a important control tool for items.
Today i am learning something about controlling list and customizing the lists.
I create a new project named "List_controls".
Now i make a new XML file in values folder  which is inside res folder and name it "array.xml".
Creating new XML file


You can see the lines of code written in array.xml file
which is shown in below image.

array.xml
I need to put listview in my layout by dragging listview from composite list .

Inserting listview in my layout


Now i  go to the activity_main.xml and write this short line of code:
android:entries="@array/colors"

array indicates the xml file which contains the items list
colors indicates the name of string array.



Now i run my project and my project looks like this.

Running my simple list_control apps.
We can also use java codes for listview but i find this way easy one.

1 comment:

Did this post help you? Do you have any questions? Drop your thoughts here...

}