Using the Master/Detail template in ViewPager Fragments (download link)

陌路散爱 提交于 2019-11-30 20:10:44

问题


Working code: https://github.com/lukeallison/ViewPagerMasterDetail

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

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.

Issues:

  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.


回答1:


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.



来源:https://stackoverflow.com/questions/35893187/using-the-master-detail-template-in-viewpager-fragments-download-link

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