android中,把data填上数据,在map中添加数据库中的数据,用listview显示。

2025-04-13 16:39:34
推荐回答(2个)
回答1:

第一种:
String[] data = {"Android应用专业开发社区:eoe.Android.com",
"eoeAndroid出品软件如下",
"eoeIntaller",
"eoeDouBan",
"eoeWhere",
"eoeInfoAssistant"};
ListView listView = new ListView(this);
listView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, data));
第二种:(自定义界面)
List> data = new ArrayList>();
Map item ;
item = new HashMap();
item.put("姓名", "张三小朋友");
item.put("性别", "男");
data.add(item);
item = new HashMap();
item.put("姓名", "小李师傅");
item.put("性别", "男");
data.add(item);
item = new HashMap();
item.put("姓名", "王五同学");
item.put("性别", "女");
data.add(item);
ListView listView = new ListView(this);
SimpleAdapter adapter = new SimpleAdapter(
this, data,
R.layout.activity_list2,
new String[]{"姓名","性别"},
new int[]{R.id.list2_1,R.id.list2_2});
listView.setAdapter(adapter);

回答2:

先表达清楚再问吧