The error is because the argument behind the case branch must be a constant, which means that the resource ID of the R.java in the library is not constant
public static final class animator {
public static int design_appbar_state_list_animator = 0x7f020001;
}
public static final class Array {
public static int card_tablist = 0x7f030001;
}
public static final class Attr {
public static int actionbardivider = 0x7f040001;
public static int actionbaritembackground = 0x7f040002;
public static int actionbarpopuptheme = 0x7f040003;
...}
As shown above, each resource ID is not declared final
The resource ID for the R.java under the project is as follows
public static final class animator {
public static final int design_appbar_state_list_animator=0x7f020000;
}
public static final class Array {
public static final int card_tablist=0x7f030000;
public static final int tab_list=0x7f030001;
}
Looked up a lot of information, except replace with If-else no other solution [Facepalm]
Reason analysis and solutions for accessing resource IDs in the Android library without using the Switch-case statement