static void setLayoutResource(@NonNull Context context, @NonNull Preference preference, @Nullable AttributeSet attrs) {
boolean foundLayout = false;
if (attrs != null) {
for (int i = 0; i < attrs.getAttributeCount(); i++) {
final String namespace = ((XmlResourceParser) attrs).getAttributeNamespace(0);
if (namespace.equals("http://schemas.android.com/apk/res/android") &&
attrs.getAttributeName(i).equals("layout")) {
foundLayout = true;
break;
}
}
}
boolean useStockLayout = false;
if (attrs != null) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.Preference, 0, 0);
try {
useStockLayout = a.getBoolean(R.styleable.Preference_useStockLayout, false);
} finally {
a.recycle();
}
}
if (!foundLayout && !useStockLayout)
preference.setLayoutResource(R.layout.md_preference_custom);
}
PrefUtil.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:GitHub
作者:
评论列表
文章目录