[Android] Enum대신 @IntDef나 @StringDef를 쓰자.

enum에 대한 최적화가 Android에서는 좀 부족하다는 이야기를 듣고
@IntDef나 @StringDef를 써야 한다 라는 것을 테스트 해봤다.

그것 관련해서
Google의 FlexboxLayout 내에서 사용하는 방식을 알게되어 아래 정리한다.
@IntDef({FlexDirection.ROW, FlexDirection.ROW_REVERSE, FlexDirection.COLUMN,        FlexDirection.COLUMN_REVERSE})
@Retention(RetentionPolicy.SOURCE)
public @interface FlexDirection {

    /**     * Main axis direction -> horizontal. Main start to     * main end -> Left to right (in LTR languages).     * Cross start to cross end -> Top to bottom     */    int ROW = 0;
    /**     * Main axis direction -> horizontal. Main start     * to main end -> Right to left (in LTR languages). Cross start to cross end ->     * Top to bottom.     */    int ROW_REVERSE = 1;
    /**     * Main axis direction -> vertical. Main start     * to main end -> Top to bottom. Cross start to cross end ->     * Left to right (In LTR languages).     */    int COLUMN = 2;
    /**     * Main axis direction -> vertical. Main start     * to main end -> Bottom to top. Cross start to cross end -> Left to right     * (In LTR languages)     */    int COLUMN_REVERSE = 3;}

댓글

이 블로그의 인기 게시물

[Android] DataBinding의 동작방식 - 4. include Tag 혹은 ViewStub 사용시의 Binding

[Android] Retrofit2, OkHttpClient Method 정리

[Android] Layout별 성능 비교[Measure 호출횟수 비교] (LinearLayout vs RelativeLayout vs ConstraintLayout)