What's the quickest way to add several views to a LinearLayout?

后端 未结 3 1102
醉酒成梦
醉酒成梦 2021-02-02 14:56

I have a LinearLayout view that already contains several elements. I want to add a lot more Views to it, programmatically. And because this is inside a Scroll

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-02 15:30

    3 Options:

    1. Replace everything with a ListView, with the other parent and custom icons as a header view for the ListView. ListView is faster, because it only creates Views as it needs them.

    2. Programatically create the contents of my_list_item instead of inflating, might be quicker

    3. Use of ViewStubs may allow you to load views on-demand.

    4. Maybe it isn't loading the views but the data? in which case prepare the data in a background thread.

提交回复
热议问题