My aim is to display people/addresses in a list - but not just a simple list, rather a list of boxes that contain several information, in my case a number, the address and a type:
The data structure for this are POJOs:
Of course, there are more than 4 entries which means that there should be a scrollbar. My first idea: a Scrollview
that contains a Linear Layout
. But I'm not sure about the content, means the boxes you can see above.
Thank you
My first idea: a Scrollview that contains a Linear Layout.
Are you familiar with a listView
? This already exists to do exactly that. I'm sure you can find dozens of tutorials on how to use them by searching.
ListActivity
class Create a separate layout file for your item
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" > <LinearLayout android:orientation="vertical" > <TextView /> <TextView /> </LinearLayout> </TextView> </LinearLayout>
ListActivity
which extends from ArrayAdapter
. In the getView()
method, use LayoutInflater
to inflate yourItemLayout and update the TextView based on the position
values. onCreate
in the main class, call setListAdapter(new InnerClass(this,R.layout.yourItemLayout,list)
You can refer customArrayAdapter to know how to custom ArrayAdapter works.
Done and dusted.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.