android listview获取其中一项的时候出现了问题
publicvoidonItemClick(AdapterView<?>arg0,Viewarg1,intarg2,longarg3){//TODOAuto-genera...
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
ListView lv = (ListView) arg0;
HashMap<String, String> map = (HashMap<String,String>) lv.getItemAtPosition(arg2);
String id = map.get("id");
String name = map.get("name");
上面这段代码在调试执行到String id = map.get("id");这一句的时候报错了,有没有大神知道是什么错误
在这个之前,我把东西放到listview里面的代码如下
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
for (EventBean p : list) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", p.getEventName());
map.put("id", p.getEventID());
data.add(map);
}
String[] from = { "id", "name" };
int[] to = { R.id.tv_id, R.id.tv_name };
SimpleAdapter adapter = new SimpleAdapter(this, data,
R.layout.event_list_item, from, to);
setListAdapter(adapter); 展开
// TODO Auto-generated method stub
ListView lv = (ListView) arg0;
HashMap<String, String> map = (HashMap<String,String>) lv.getItemAtPosition(arg2);
String id = map.get("id");
String name = map.get("name");
上面这段代码在调试执行到String id = map.get("id");这一句的时候报错了,有没有大神知道是什么错误
在这个之前,我把东西放到listview里面的代码如下
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
for (EventBean p : list) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", p.getEventName());
map.put("id", p.getEventID());
data.add(map);
}
String[] from = { "id", "name" };
int[] to = { R.id.tv_id, R.id.tv_name };
SimpleAdapter adapter = new SimpleAdapter(this, data,
R.layout.event_list_item, from, to);
setListAdapter(adapter); 展开
2015-06-15
展开全部
get(Object key)
返回指定键所映射的值茄谨;如果让罩此映射不包含该键的映射颤滑基关系,则返回 null。
返回指定键所映射的值茄谨;如果让罩此映射不包含该键的映射颤滑基关系,则返回 null。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询