Generally speaking, we understand the ListView ListControl, list some of the items displayed in the form or content. Just as today we list some of the items, list it in the App will show the fact.
First, as a new Android Project Open listcontrol then main.xml layout file that contains a blank day. Graphics layout palette to the left of the layout folder a Linearlayout, Graphics Layout of the drop. Composite folder on the LinearLayout Another Listview, Graphics Layout of the drug on the left and layout_width and layout_height, match_parent day. Besides main.xml file in listview android: id theandroid: id / list has been created to give him directions habeapatata GraphicsLayout us. Now we need to create a file which contains the following items, where our list. Maine folder res> value of an xml file enatuna create folders and resource use in the Declare.>
Now we'll do our Main.java file.
Our Main Java file that contains public class MainActivity extends Activity extends ListActivity day. Then to display listview will give us a listAdapter sets. And it has to Declare,
When you type the new ArrayA type setListAdapter Clt + space to the press the widget ArrayAdapter <T> (context, resource, textViewResourceId) to choose it. Type String and context you need to be here this. And as mentioned above, you need to rest. R.array.listitems here in the string array that will taciniye Id was taken. Now Main.java runs will show the items on the list.
This project's source code from the download Take
First, as a new Android Project Open listcontrol then main.xml layout file that contains a blank day. Graphics layout palette to the left of the layout folder a Linearlayout, Graphics Layout of the drop. Composite folder on the LinearLayout Another Listview, Graphics Layout of the drug on the left and layout_width and layout_height, match_parent day. Besides main.xml file in listview android: id theandroid: id / list has been created to give him directions habeapatata GraphicsLayout us. Now we need to create a file which contains the following items, where our list. Maine folder res> value of an xml file enatuna create folders and resource use in the Declare.>
ooeyasinoo Code highlight - Double-click on the code, copy the code to <string-array name=
"listitems"
>
<item name=
"item1"
>Item1</item>
<item name=
"item2"
>Item2</item>
<item name=
"item3"
>Item3</item>
<item name=
"item4"
>Item4</item>
<item name=
"item5"
>Item5</item>
</string-array>
Now we'll do our Main.java file.
Our Main Java file that contains public class MainActivity extends Activity extends ListActivity day. Then to display listview will give us a listAdapter sets. And it has to Declare,
ooeyasinoo Code highlight - Double-click on the code, copy the code to
setListAdapter(
new
ArrayAdapter
(
this
,android.R.layout.simple_list_item_1,
getResources().getStringArray(R.array.listitems)));
When you type the new ArrayA type setListAdapter Clt + space to the press the widget ArrayAdapter <T> (context, resource, textViewResourceId) to choose it. Type String and context you need to be here this. And as mentioned above, you need to rest. R.array.listitems here in the string array that will taciniye Id was taken. Now Main.java runs will show the items on the list.
This project's source code from the download Take
No comments:
Post a Comment