Advantage of ListFragment over a ListView or normal Fragment

前端 未结 1 1385
无人及你
无人及你 2021-02-01 17:10

I have an activity with a menu of items running down the left side that are textViews. when the user selects one of the textViews it will put a listView in the rest of the area

相关标签:
1条回答
  • 2021-02-01 17:53

    A ListFragment is basically a slightly specialized Fragment which makes handling a ListView present in the layout of the Fragment easier by offering some convenience methods(like getListView() so you don't need to search for the widget yourself, a method to get the adapter of the ListView etc). If you need a Fragment with a ListView, use a ListFragment. So in the end it's about deciding between a ListView and a ListFragment.

    Between the two options, taking in consideration your scenario, I would simply use a ListViewbecause it's plain simple. The need of a Loader isn't a problem as you could use the LoaderManager of the Activity for the ListView.

    However, you didn't mention how the BACK button should be handled. If you want to offer the user the possibility of navigating back through his choices use a Listfragment to get that for free from the system.

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