我想显示字符串数组的某个部分,而不是其他部分.字符串数组用于国家/地区、国家/地区代码和每个国家/地区的 iso



好的,下面是我的xml代码片段:

<string-array name="country_data">
<item>
<font color="#7c7b7b">
<country>Afghanistan</country>
<countryCode>93</countryCode>
<iso2>AF</iso2>
<iso3>AFG</iso3>
</font>
</item>

我想在微调器对象中仅显示国家/地区。我可以显示所有数据,如果我在项目中只有国家/地区,我可以这样做,但我希望那里的其余数据在需要时也能在其他地方引用。

我的安卓Java代码如下:

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.country_data, android.R.layout.simple_spinner_item);

country_data 是字符串数组的名称。 我应该更改/添加什么以仅显示阿富汗而不是阿富汗 93 AF AFG

我认为您需要对xml字段的映射进行建模/创建

你可以试试这个文档 https://developer.android.com/training/basics/network-ops/xml

最新更新