在学习android listView控件的时候...按照预定从数据库中读取内容显示,可显示的结果叫人摸不着头脑,如图所示,显示的全部都是false
呵呵....我测试过,从数据库中读取的内容是正确的....
如果有遇到这样的结果的朋友 希望给与解答...在此谢谢了....
List<Person> persons = personServiceInter.getScrollData(0, 20);
List<HashMap<String, Object>> data = new ArrayList<HashMap<String,Object>>();
for (Person person : persons){
HashMap<String, Object> item = new HashMap<String, Object>();
item.put("name", person.getName());
item.put("phone", person.getPhone());
item.put("amount", person.getAmount());
data.add(item);
}
SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.item,
new String[]{"name", "phone", "amount"}, new int[]{R.id.name, R.id.phone, R.id.amount});
listView.setAdapter(adapter);

------解决方案--------------------
应该没错误,但是反过来想,为什么又会出现false这个值呢,不知道你有没有测试过data里面的值是否正确,,,,
------解决方案--------------------
测测你得到的person的值,在data.add(item)之前看看得到的3个数据的值是什么
------解决方案--------------------
那应该是显示的问题,listView 的布局在哪里填充的,有没有setContextView(listView);