在 ViewPager Fragments 中使用 Master/Detail 模板(下载链接) [英] Using the Master/Detail template in ViewPager Fragments (download link)

查看:14
本文介绍了在 ViewPager Fragments 中使用 Master/Detail 模板(下载链接)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

工作代码: https://github.com/lukeallison/ViewPagerMasterDetail

Android Master/Detail Flow 模板: http://developer.android.com/tools/projects/templates.html#master-detail-activity

说明:使用 Android Studio 中可用的 Master/Detail Flow 模板,我的应用程序利用 ViewPager 来管理三个 Parent 片段.第三个片段是 Master(列表),其中有一个 Child(详细)片段.

Description: Using the Master/Detail Flow template available in Android Studio, my application utilizes a ViewPager to manage three Parent fragments. The third fragment is a Master (list), which has a Child (detail) fragment.

问题:

  1. 当 fragment_item_list 首次膨胀时,应用栏会将列表的最后一项推到屏幕边界下方.旋转设备后,此问题不再存在.只需在屏幕底部添加填充不会解决问题,因为它会在旋转后在屏幕底部留下不需要的空间.许多 SO 线程未能解决此问题.- 已修复
  2. 需要 android:configChanges="orientation|keyboardHidden|screenSize" 以便子(细节)片段在旋转时膨胀正确的布局.我不想强制执行此操作.请帮助修复此错误.
  3. 使用已弃用的 setOnPageChangeListener 和 onAttach(Activity)
  4. 将依赖项升级到 23.2.0 会导致 ItemListFragment 在旋转时无法膨胀正确的 Fragment,因此我无法更新应用程序中的库
  5. 代码可能比必要的更繁琐
  1. When fragment_item_list is first inflated the App Bar pushes the last item of the list below the bounds of the screen. This issue is no longer present after rotating the device. Simply adding padding to the bottom of the screen will not fix the issue as it will leave an unwanted space at the bottom of the screen after rotating. Numerous SO threads have failed to address this issue. - Fixed
  2. Requires android:configChanges="orientation|keyboardHidden|screenSize" in order for the Child (detail) fragment to inflate the correct layout when rotated. I'd like to not have to enforce this. PLEASE help fix this bug.
  3. Uses deprecated setOnPageChangeListener and onAttach(Activity)
  4. Upgrading the dependencies to 23.2.0 results in the ItemListFragment failing to inflate the correct Fragment when rotated so I can't update the libraries in the application
  5. The code is probably more cumbersome than necessary

请帮我修复这些错误,以便我们有一个我自己和其他人都可以使用的模板.

Please help me fix these bugs so we have a template that myself and others can use.

推荐答案

Bug 修复.fragment_item_list.xml 中的列表现在在初始和后续布局膨胀时显示列表的最后一个元素.我将 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 添加到 style.xml 和 ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar); 到 ItemListFragment.java 的 initLayout 方法.

Bug fix. The List in fragment_item_list.xml now displays the last element of the List on initial and subsequent layout inflation. I added <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> to style.xml and ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar); to the initLayout method of ItemListFragment.java.

这篇关于在 ViewPager Fragments 中使用 Master/Detail 模板(下载链接)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆