anroid直接应用系统资源,编译无法通过,此时可以通过反射或者系统提供的api来获取资源对象.
Resources.getSystem().getIdentifier(String name, String defType, String defPackage);
eg:
int layoutRes = Resources.getSystem().getIdentifier("transient_notification", "layout", "android");
View layout = inflater.inflate(layoutRes, null);
//View layout = inflater.inflate(com.android.internal.R.layout.transient_notification, null);
int idRes = Resources.getSystem().getIdentifier("message", "id", "android");
TextView textView = layout.findViewById(idRes);
//TextView textView = layout.findViewById(com.android.internal.R.id.message);