Skip to content

Instantly share code, notes, and snippets.

View sonvp's full-sized avatar

son vo sonvp

  • son.vo@hdwebsoft.com
View GitHub Profile
@modjke
modjke / LinearLayoutPagerManager.java
Last active November 7, 2022 23:50
RecyclerView's LinearLayoutManager with the ability to set a fixed number of items to be displayed
package ;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
public class LinearLayoutPagerManager extends LinearLayoutManager {
private int mItemsPerPage;
@danielesegato
danielesegato / AndroidBug-OptionItems-Fragments-29472-workaround.md
Last active March 27, 2019 13:40
Android Option Menu + Fragments Workaround with ViewPager / ActionBar / Drawer, Menu Items not displaying

This gist is a workaround to this bug:

https://code.google.com/p/android/issues/detail?id=29472

No changes are needed to your current code but changing the extended fragment/activity class.

All you have to do is put this two classes in your code and make your activity extend MenuManagerActivity and your fragment MenuDelegatorFragment. If you are using Nested fragment you must make sure that all fragments containing nested Fragments with options menu also extend MenuDelegatorFragment (both if the parent fragment need an option menu both if it doesn't need it).