[英]how implement an android sidebar menu?
what is best solution to implement a sidebar menu like below ?实现如下侧边栏菜单的最佳解决方案是什么? items of sidebar and the content of each section comes from server(count of items is variable)
侧边栏项目和每个部分的内容来自服务器(项目数是可变的)
i want some advices about view implementation for best performance in implementation我想要一些关于视图实现的建议,以获得最佳的实现性能
You can get help with complete code from Material Design.您可以从 Material Design 获得有关完整代码的帮助。 And click here to visit the site
并点击这里访问该网站
For section items at Right, you can use RecyclerView with GridLayoutManager.对于右侧的部分项目,您可以将 RecyclerView 与 GridLayoutManager 一起使用。
For the section list (on the left side) There are two possibilities based on the UI requirements.对于部分列表(在左侧),根据 UI 要求有两种可能性。
On the other hand, if you'll use view pager that will not be good for performance since there can be even more then 10 lists.另一方面,如果您将使用视图寻呼机,这对性能不利,因为可能有超过 10 个列表。
So you can display both lists in a Fragment and load the data in the repository.因此,您可以在 Fragment 中显示两个列表并在存储库中加载数据。 And on response send data to fragment using Live data and ViewModel.
并在响应时使用实时数据和 ViewModel 将数据发送到片段。 update the RecyclerViews in live data observer.
在实时数据观察器中更新 RecyclerViews。 Update Contents based on selected section
根据所选部分更新内容
Read about recyclerviewRead about Navigation menu 阅读关于 recyclerview阅读关于导航菜单
In this situation i found the best solution to use recycler-view for left-hand sidebar menu(because this is easy to use and handle)在这种情况下,我找到了将回收器视图用于左侧边栏菜单的最佳解决方案(因为这易于使用和处理)
and i used single fragment to showing content for each sidebar-menu item and caching content for later use(click action by user)我使用单个片段来显示每个侧边栏菜单项的内容并缓存内容供以后使用(用户单击操作)
I prefer do not use the navigation menu for three reason :我更喜欢不使用导航菜单的三个原因:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.