我用俄语单词阅读 XML:
xpp = factory.newPullParser();
file = new File(getFilesDir()+"/shops.xml");
fis = null;
fis = new FileInputStream(file);
xpp.setInput(new InputStreamReader(fis));
eventType = 0;
eventType = xpp.getEventType();
do
{
if (eventType == XmlResourceParser.START_TAG)
{
String strName = xpp.getName();
if (strName.equals("Shop"))
{
String nameSh = xpp.getAttributeValue(null, "name");
Shops.add(nameSh);
}
}
eventType = xpp.next();
}
while (eventType != XmlResourceParser.END_DOCUMENT);
UTF 格式的文件 - 但是当我在对话框中显示字符串数组时,我无法读取这些单词。
protected Dialog onCreateDialog(int id) {
AlertDialog.Builder adb = new AlertDialog.Builder(MainActivity.this);
adb.setTitle(R.string.items);
String[] Shopsx=new String[Shops.size()];
for(int k=0;k<Shops.size();k++)
{
Shopsx[k]=Shops.get(k);
}
adb.setSingleChoiceItems(Shopsx, -1, myClickListener);
adb.setPositiveButton(R.string.ok, myClickListener);
return adb .create();
}
我的 XML:
<?xml version='1.0' encoding='Utf-8' ?>
<Shops>
<Shop name="Первый" ></Shop>
<Shop name="Второй"></Shop>
<Shop name="Третий"></Shop>
</Shops>
我希望看到带有 3 个复选框(Первый、Второй、Третий)的列表,但看到带有黑色菱形的列表。如果在xml英文单词中使用,查看是可以的。能不能帮忙找一下,有什么问题。