我想尝试将数据作为一行添加到数据库中。但我无法将其添加为一行。
这是我的logcat我想在数据库中添加如下数据: -
10-20 10:49:43.311 12107-12107/com.refresh.pos E/key..::>>: quantity
10-20 10:49:43.311 12107-12107/com.refresh.pos E/value..::>>: 1
10-20 10:49:43.311 12107-12107/com.refresh.pos E/key..::>>: price
10-20 10:49:43.311 12107-12107/com.refresh.pos E/value..::>>: 10.0
10-20 10:49:43.311 12107-12107/com.refresh.pos E/key..::>>: name
10-20 10:49:43.311 12107-12107/com.refresh.pos E/value..::>>: bnana
10-20 10:49:43.311 12107-12107/com.refresh.pos E/key..::>>: quantity
10-20 10:49:43.311 12107-12107/com.refresh.pos E/value..::>>: 1
10-20 10:49:43.311 12107-12107/com.refresh.pos E/key..::>>: price
10-20 10:49:43.312 12107-12107/com.refresh.pos E/value..::>>: 15.0
10-20 10:49:43.312 12107-12107/com.refresh.pos E/key..::>>: name
10-20 10:49:43.312 12107-12107/com.refresh.pos E/value..::>>: lemon
我想在数据库中添加项目,如: -
three fields :- quantity price name
1 10.0 bnana
1 15.0 lemon
我希望现在有人能理解我想做的事。
这是我将适配器设置为listview并从Map获取密钥和值的代码: -
private void showList(List<LineItem> list) {
saleList = new ArrayList<Map<String, String>>();
for (LineItem line : list) {
saleList.add(line.toMap());
}
SimpleAdapter sAdap;
sAdap = new SimpleAdapter(getActivity().getBaseContext(), saleList,
R.layout.listview_lineitem, new String[]{"name", "quantity", "price"}, new int[]{R.id.name, R.id.quantity, R.id.price});
saleListView.setAdapter(sAdap);
for (Map<String, String> map : saleList) {
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry pair = (Map.Entry) iterator.next();
Log.e("key..::>>", "" + pair.getKey());
Log.e("value..::>>", "" + pair.getValue());
}
}
}
任何人都可以告诉我如何将数据添加为我以关键和值形式获取的行。