本文整理匯總了Java中android.content.res.XmlResourceParser.nextTag方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlResourceParser.nextTag方法的具體用法?Java XmlResourceParser.nextTag怎麽用?Java XmlResourceParser.nextTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.XmlResourceParser
的用法示例。
在下文中一共展示了XmlResourceParser.nextTag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: retrieveSupportedDevices
import android.content.res.XmlResourceParser; //導入方法依賴的package包/類
private static void retrieveSupportedDevices(final Resources resources) {
final String tag = "retrieveDeviceData - ";
if (supportedDevices == null) {
final List<SupportedDevice> result = new ArrayList<>();
final XmlResourceParser xml = resources.getXml(R.xml.supported_devices);
try {
xml.next();
int eventType;
while ((eventType = xml.getEventType()) != XmlPullParser.END_DOCUMENT) {
switch (eventType) {
case XmlPullParser.START_TAG:
if (xml.getName().equals("usb-device")) {
final AttributeSet as = Xml.asAttributeSet(xml);
final Integer vendorId = parseInt(as.getAttributeValue(null, "vendor-id"));
final Integer productId = parseInt(as.getAttributeValue(null, "product-id"));
// Read description
String description=null;
xml.next();
if (xml.getName().equals("description")) {
xml.require(XmlPullParser.START_TAG, null, "description");
if (xml.next() == XmlPullParser.TEXT) {
description = xml.getText();
xml.nextTag();
}
xml.require(XmlPullParser.END_TAG, null, "description");
}
result.add(new SupportedDevice(new Pair<>(vendorId, productId), description));
}
break;
}
xml.next();
}
} catch (XmlPullParserException | IOException e) {
Log.e(TAG, tag, e);
}
supportedDevices = result;
}
}