
Layout_width: It sets the width of the layout. TextSize: It sets the size of the text that will be displayed. ChoiceMode: It sets the number of items that can be selected at once. Background can be either color or even an image. Background: It sets the background of the ListView. Entries: This specifies the reference to the array resource. Items.listSelector: This property sets the selector for listView. DividerHeight: This defines the height of the divider between list. Divider: This defines the color or drawable among different list items. To customize the ListView in Android, we can add certain attributes to it, such as: To add a ListView in our application we define it using the following:. Id: Id is used to uniquely identify a view. Position: It tells the position of the selected item in the array. View: This tells the specific view that was selected. ListView: This contains the item of the view.
We can also set the action to be processed after a list item is clicked using the onListItemClick() method. An adapter holds the data and sends it to the Adapter view after that View takes the data from the adapter view and shows it in ListViews. An adapter basically bridges between the UI component and the data source for items. The items are added automatically using Adapter. It shows the list in vertical form and it becomes scrollable automatically. It is the most basic but one of the most important UI components in Android. In ListView the list layout is created using ListView. ListView in Android is a type of ViewGroup that shows the list of items in the form of rows.
We offer you a brighter future with FREE online courses Start Now!!