急~!Android listView 怎么样显示条数? 比如:数据的条数不确定有的有5条,有的有4条应该怎么显示
例:物品A:item1:item2:item3:物品B:item1item2:简单说有几条就显示几条!回答得好还加分~!...
例: 物品A: item1:
item2:
item3:
物品B:item1
item2:
简单说 有几条就显示几条!
回答得好 还加分~! 展开
item2:
item3:
物品B:item1
item2:
简单说 有几条就显示几条!
回答得好 还加分~! 展开
展开全部
SimpleAdapter adapter = new SimpleAdapter(DialogListDemo.this,
getData(), R.layout.listview, new String[] { "text",
"text1", "text2", "img" }, new int[] {
R.id.L_TextView01, R.id.L_TextView03,
R.id.L_TextView04, R.id.L_ImageButton01 });
lv.setAdapter(adapter);
private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
Cursor cur = DR.query("myuser", new String[] { "userID", "psd" ,"repsd"}, null,
null, null, null, null);
while (cur.moveToNext()) {
String name2 = cur.getString(0);
String psd2 = cur.getString(1);
String repsd= cur.getString(2);
map.put("text",repsd);
map.put("text1", name2);
map.put("text2", psd2);
map.put("img", R.drawable.a35);
list.add(map);
// }
}
我这里面是写数据插入的(片段代码) ,所以不确定要插入多少个 应用while (cur.moveToNext()) {
}用游标对数据库进行遍历 然后插入到listview里面
getData(), R.layout.listview, new String[] { "text",
"text1", "text2", "img" }, new int[] {
R.id.L_TextView01, R.id.L_TextView03,
R.id.L_TextView04, R.id.L_ImageButton01 });
lv.setAdapter(adapter);
private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
Cursor cur = DR.query("myuser", new String[] { "userID", "psd" ,"repsd"}, null,
null, null, null, null);
while (cur.moveToNext()) {
String name2 = cur.getString(0);
String psd2 = cur.getString(1);
String repsd= cur.getString(2);
map.put("text",repsd);
map.put("text1", name2);
map.put("text2", psd2);
map.put("img", R.drawable.a35);
list.add(map);
// }
}
我这里面是写数据插入的(片段代码) ,所以不确定要插入多少个 应用while (cur.moveToNext()) {
}用游标对数据库进行遍历 然后插入到listview里面
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询