Recycling views inside a horizontal scrollview android

偶尔善良 提交于 2019-12-12 02:22:38

问题


I'm making an app with fairly complex UI. Its comparable to a horizontal list view that expands to a viewpager on being clicked. Presently, I've implemented this using the most basic approach. I simply inflate views inside a horizontalScrollView and inflate another subview with animation whenever user taps on any parent view.

This works perfectly fine and gives it a look of horizontal expandable listview. However, I feel this approach is highly inefficient since I keep on getting GC warnings almost every few seconds thereby reducing performance. And in this approach I'm not even recyling views like listview does.

My questions are:

  • Is there any other efficient way of doing this ?
  • How could I recycle views in my existing code like listview does?

Thanks!

(Please don't recommend using Gallery. My view is fairly complex)


回答1:


Is there any other efficient way of doing this ?

Use ViewPager or the open source HorizontalListView, both of which use the adapter pattern.



来源:https://stackoverflow.com/questions/15000702/recycling-views-inside-a-horizontal-scrollview-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!