我已经像这样将一些值存储到 ArrayList HashMap 中:
ArrayList<HashMap<String, String>> bookDetails = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
map.put("book_author", bookAuthor);
map.put("book_description", bookDescription);
bookDetails.add(map);
我只是希望能够检索描述值并将其显示在 TextView 中,我该怎么做呢?提前致谢。
最佳答案
像这样的东西应该可以工作:
TextView text = (TextView) findViewById(R.id.textview_id);
text.setText(bookDetails.get(0).get("book_description"));
除了调用 get(0)
,您当然也可以遍历 bookDetails
数组并获取当前迭代计数器变量,例如获取(n)
关于java - 从 ArrayList HashMap<String, String> 中的键/值中检索值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21612415/