RecyclerView vs. ListView

前端 未结 16 1707
名媛妹妹
名媛妹妹 2020-11-22 06:07

From android developer (Creating Lists and Cards):

The RecyclerView widget is a more advanced and flexible version of ListView.

<
16条回答
  •  囚心锁ツ
    2020-11-22 06:35

    1. You can use an interface to provide a click listener. I use this technique with ListViews, too.
    2. No divider: Simply add in your row a View with a width of match_parent and a height of 1dp and give it a background color.
    3. Simply use a StateList selector for the row background.
    4. addHeaderView can be avoided in ListViews, too: simply put the Header outside the View.

    So, if efficiency is your concern, then yes, it's a good idea to replace a ListView with a RecyclerView.

提交回复
热议问题