Notes ListView class (list view):

Indirectly inherited from ViewGroup, it belongs to the container class component. It is usually used to provide a series of selectable list items for users to choose, so as to facilitate users.
List view is the most commonly used view component in Android. It lists the need to be displayed in the form of a vertical list. List items, such as the common XML attributes of ListView in the contact list of the WeChat address book interface
:

android:divider is used to set the divider for the list view, which can be separated by color or Drawable resources
android:dividerHeight is used to set the height of the divider
android:entries is used to specify list items for ListView through array resources
android:footerDividersEnabled It is used to set whether to draw the divider bar before the footer View (bottom view). The default value is true. When set to false, it means no drawing. When using this attribute, you need to set the footer View
android for the ListView through the addFooterView() method provided by the ListView component :headerDividersEnabled is used to set whether to draw the divider after the header View (head view), the default value is true, when set to false, it means not to draw, when using this property, you need to use the addHeaderView() method provided by the ListView component to ListView Set footer view

If you do not use the android:entries attribute to specify the list items to be displayed for the ListView, you can also specify the list items that need to be displayed by setting the Adapter for it:
a) Create an Adapter object. For a plain text list item, you usually use the ArrayAdapter object to create The ArrayAdapter object can usually be created in two ways, one is to create it through an array resource file; the other is to create it by using a string array in a Java file. When creating an ArrayAdapter object for the ListView, you also need to specify the appearance of the list item:

simple_list_item_1 Each list item is a normal text
simple_list_item_2 Each list item is a normal text (the font is slightly larger)
simple_list_item_checked Each list item has a selected list item
simple_list_item_multiple_choice Each list item is with a check The text of the box
simple_list_item_single_choice Each list item is text with radio buttons

b) Associate the created adapter object with the ListView, which can be achieved through the setAdapter() method of the ListView object

ListView object name.setAdapter(Adapter object name);

Guess you like

Origin blog.csdn.net/qq_42823109/article/details/93452037