0

How can I display information in the following format? What controls should I use, listView or RecycleView?

Note that the question isn't about this particular activity and how to use it. It's about how to show the information in the same format and how to create the layout for it.

enter image description here

Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
  • 1
    You can go for Recycler View/List View within your Activity and have 2 TextView as base view for that View. – Shadow Droid Oct 26 '15 at 16:40
  • @ShadowDroid which one is more recommendable? – Alan Coromano Oct 26 '15 at 16:41
  • Just adding some input, that type of layout is typical of PreferenceActivity (http://developer.android.com/reference/android/preference/PreferenceActivity.html) although they lack flexibility. – Edson Menegatti Oct 26 '15 at 16:43
  • I prefer Recycler View. Because as per official docs :The RecyclerView widget is a more advanced and flexible version of ListView. It also simplifies your maintenance of code by separating creation of view and binding of data for more details refer https://developer.android.com/training/material/lists-cards.html Also you can try what Edson suggested – Shadow Droid Oct 26 '15 at 16:48

2 Answers2

1

That is a ListView. You would just need a ListAdapter/ArrayAdapter to fill it and that's about it.

Shark
  • 6,513
  • 3
  • 28
  • 50
  • No need for a RecyclerView based on the info you provided. – Shark Oct 26 '15 at 16:42
  • and how to create a simple layout for that, that is, how can I have one header label and one description label in each list-item? Are those actually 2 different labels? – Alan Coromano Oct 26 '15 at 16:51
  • Yes they are. The adapter will fill both of them with values. The screenshot you attached is pretty much the textbook example of using a ListView, look up a few tutorials and you probably won't have any problems creating it. The list is full of sub-views, each with their own layout. So the subview's layout will probably be just two TextViews, one above the other, upper one being black, lower one being gray. That's about it, the layout will be inflated and the values will be filled in Adapter's `getView()` method. – Shark Oct 26 '15 at 16:54
1

You can make exactly the same thing using the layout simple_expandable_list_item_2 in the SimpleAdapter of a ListAdapter (here is how you do it : Displaying kind of static data in ListView)

RecyclerView is of course much better in terms of performance and flexibility. However, ListView is enough in many cases like this one.

Community
  • 1
  • 1
Hichem Acher
  • 433
  • 2
  • 16