我在 Android 资源中有 5 个文件(test1、test2、test3、test4、test5)。所有资源都应该分配给变量parser。应该如何正确完成?
公共类 MainActivity 扩展 Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
XmlResourceParser parser = getResources().getXml(R.xml.test1);
databaseHelper myDbHelper = new databaseHelper(this);
try {
//myDbHelper = new databaseHelper(this);
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if (name.equals("test") || name.equals("test")) {
String id = null, gname = null, pob = null, pob1 = null, memb = null, seq = null, site = null;
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
name = parser.getName();
if (name.equals("test")) {
id = readText(parser);
} else if (name.equals("test")) {