我不会用字典。它是
obsolete
.我认为你最好用
ArrayList
习惯的
Object
s或a
HashMap
.那你就可以拿到这个了
对象
来自您的
Adapter
以下为:
listview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//adapter.getItem(position); - this is how you can acces the object
//connected to the selected item from the list
//Then you can easily access an id of this object (or from HashMap)
}
});
编辑:如果你想有一个xml列表,你可以随时向你的资源中添加一个抽象的xml文件。这些也可以本地化。它是这样的:
<my_word>
<id>123</id>
<word>My word</word>
</my_word>
但它将涉及XML解析,所以不一定是更容易的解决方案。