Tuesday, July 5, 2016

A great article about ViewPager and using it without fragments: https://www.bignerdranch.com/blog/viewpager-without-fragments/

public enum CustomPagerEnum {
 
    RED(R.string.red, R.layout.view_red),
    BLUE(R.string.blue, R.layout.view_blue),
    ORANGE(R.string.orange, R.layout.view_orange);
    

    private int mTitleResId;
    private int mLayoutResId;
 
    CustomPagerEnum(int titleResId, int layoutResId) {
        mTitleResId = titleResId;
        mLayoutResId = layoutResId;
    }
 
    public int getTitleResId() { return mTitleResId; }
    public int getLayoutResId() { return mLayoutResId; }
}


OK, What The FUCK, Java?????????????

Why is there a constructor, local variables, and methods (did I miss anything?) in a fucking enum???

Oh, wait, I did miss something (corollary of having a constructor): RED, BLUE, and ORANGE are not constant integral values like in any other language. How on Mother Earth is this an enum???

Why not just call it a class with public static final members???

No comments:

Post a Comment