且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

HashMap的错误,我不能加载从字符串数据

更新时间:2022-10-21 23:31:09

R.string.information 只是一个 INT 。如果你想实际字符串,用

  map.put(名,的getString(R.string.information));

I m using hashmap for a listview.

    map = new HashMap<String, Object>();
    map.put("name", R.string.information);
    map.put("address", R.drawable.info3);

    mylist.add(map);
    // ...

my problem is that i cant load string in my hashmap (R.string.information)..when i run it,i can only see some numbers instead of my text..am i doing something wrong?thanks

        <string name="information">Informations</string>

R.string.information is just an int. If you want the actual String, use

map.put("name", getString(R.string.information));