How to add a sub item in Android ListView?

前端 未结 4 791
礼貌的吻别
礼貌的吻别 2021-02-08 16:03

I have made a android listView taking the help from Vogella.com using following layout and ListActivity class.

RowLayout.xml



        
相关标签:
4条回答
  • 2021-02-08 16:35

    A ListView item can have it's own custom layout. When you create your adapter for the ListView you can pass in the layout id to the Adapter constructor. See SimpleAdapter and ArrayAdapter.

    If you want to show some more details like image and text or two textview then You will have to extend an Adapter and implement getView() to property set the image+text.

    Check out Custom ListView

    And if you want to categorize the ListView in sections then you should go for the Section ListView in Android also check Section Header in ListView

    0 讨论(0)
  • 2021-02-08 16:40

    For that you have to create custom list view. Here is the Link...

    0 讨论(0)
  • 2021-02-08 16:45

    You can use the built-in android.R.layout.simple_list_item_2 to create two line textView.

    enter image description here

    0 讨论(0)
  • 2021-02-08 16:53

    In order to add sub items to your items in List View, Use Expandable List View.

    Have a look at this example.

    You can ask if you have any further queries :)

    0 讨论(0)
提交回复
热议问题