如何检查从上一个活动传递的捆绑包是否为@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?
...
}
最佳答案
添加。//noinspection ResourceTypemRegion = getArguments().getString("region");