Listview Displays a vertically-scrollable collection of views, where each view is positioned immediately below the previous view in the list. For a more modern, flexible, and performant approach to displaying lists, use RecyclerView.
To display a list, you can include a list view in your layout XML file:
<ListViewandroid:id="@+id/list_view"android:layout_width="match_parent"android:layout_height="match_parent" />
To make it scrollable you need to add: android:scrollbars=”vertical”xml file looks as below: <?xml version="1.0" encoding="utf-8"?><relativeLayoutandroid:id="@+id/widget32"android:layout_width="fill_parent"android:layout_height="fill_parent"xmlns:android="http://schemas.android.com/apk/res/android"> <listView android:id="@+id/listview" android:scrollbars="vertical" android:layout_width="fill_parent" android:layout_height="200dip" android:layout_gravity="fill_vertical" android:layout_alignParentTop="true" > </listView></relativeLayout>Now the java file snippet looks like:
|
No comments:
Post a Comment