本文整理汇总了Java中android.content.res.XmlResourceParser.getAttributeBooleanValue方法的典型用法代码示例。如果您正苦于以下问题:Java XmlResourceParser.getAttributeBooleanValue方法的具体用法?Java XmlResourceParser.getAttributeBooleanValue怎么用?Java XmlResourceParser.getAttributeBooleanValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.XmlResourceParser
的用法示例。
在下文中一共展示了XmlResourceParser.getAttributeBooleanValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readValidCertificates
import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
private Map<String, ArrayList<CallerInfo>> readValidCertificates(XmlResourceParser parser) {
HashMap<String, ArrayList<CallerInfo>> validCertificates = new HashMap<>();
try {
int eventType = parser.next();
while (eventType != XmlResourceParser.END_DOCUMENT) {
if (eventType == XmlResourceParser.START_TAG
&& parser.getName().equals("signing_certificate")) {
String name = parser.getAttributeValue(null, "name");
String packageName = parser.getAttributeValue(null, "package");
boolean isRelease = parser.getAttributeBooleanValue(null, "release", false);
String certificate = parser.nextText().replaceAll("\\s|\\n", "");
CallerInfo info = new CallerInfo(name, packageName, isRelease);
ArrayList<CallerInfo> infos = validCertificates.get(certificate);
if (infos == null) {
infos = new ArrayList<>();
validCertificates.put(certificate, infos);
}
/*Log.v(TAG, "Adding allowed caller: " + info.name +
" package=" + info.packageName + " release=" + info.release +
" certificate=" + certificate);*/
infos.add(info);
}
eventType = parser.next();
}
} catch (XmlPullParserException | IOException e) {
Log.e(TAG, e + "Could not read allowed callers from XML.");
}
return validCertificates;
}
示例2: loadFromXml
import android.content.res.XmlResourceParser; //导入方法依赖的package包/类
private void loadFromXml(int resourceId) {
XmlResourceParser parser = getContext().getResources().getXml(
resourceId);
try {
int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_DOCUMENT) {
} else if (eventType == XmlPullParser.START_TAG) {
String name = parser.getName();
if (!TextUtils.isEmpty(name) && name.equals("animation-list")) {
int size = parser.getAttributeCount();
for (int i = 0; i < size; i++) {
if (parser.getAttributeName(i).equals(
"oneshot")) {
mLoop = !parser.getAttributeBooleanValue(
i, true);
}
}
}
if (parser.getName().equals("item")) {
for (int i = 0; i < parser.getAttributeCount(); i++) {
if (parser.getAttributeName(i).equals(
"drawable")) {
int resId = Integer.parseInt(parser
.getAttributeValue(i)
.substring(1));
if (resId != 0)
mRes.add(resId);
} else if (parser.getAttributeName(i)
.equals("duration")) {
duration = parser.getAttributeIntValue(
i, 1000);
}
}
}
} else if (eventType == XmlPullParser.END_TAG) {
} else if (eventType == XmlPullParser.TEXT) {
}
eventType = parser.next();
}
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e2) {
e2.printStackTrace();
}
}