ListView In Android
"ListView"
Hi friends, Today we are going to learn what is listView and how to implement in android?
ListView is group of items and all items are display in vertical scrollable view. The list items are inserted in listview by using adapter. Here using ArrayAdapter and We will learn Base adapter in next tutorial.
Lets start to implement listview with array adapter in android.
- Create one layout file that contains following code. Here the name of file is "activity_main.xml"
In above file we have added ListView and set an id "list_demo".
- Now create one java file and paste the following code. Here the name of file is "MainActivity.java"
After executing the above code, it will show one list that contains six items in vertical scrollable view.
- To get an selected item from list use the following code.
- To delete an list item by long press on listview item use the following code snippets. The listAdapter.notifyDataSetChanged(); used to refresh list after removing data from ListView.
In next tutorial will learn about custom listview and BaseAdapter.
Enjoy coding!😊
To get a full source code click on below button
Comments
Post a Comment