Android,Java)以@StringDef的形式检索Bundle数据?

时间:2016-12-15 13:10:31

标签: java android enums

如何检查从前一个Activity传递的包是否是@StringDef?

之一
@Retention(RetentionPolicy.SOURCE)
@StringDef({Region.RegionA, Region.RegionB, Region.RegionC})
public @interface Region {
    String RegionA = "a";
    String RegionB = "b";
    String RegionC = "c";
}


private @Region String mRegion;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ...
    mRegion = getArguments().getString("region"); // Check if this is @Region?
    ...

}

0 个答案:

没有答案