如何ListView的内容发送到SQLite数据库 [英] How to send ListView contents to Sqlite database

查看:125
本文介绍了如何ListView的内容发送到SQLite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

活动过程

adapter=new ArrayAdapter<String>(this,
R.layout.salelistitems,R.id.saleNotes,listItems);
setListAdapter(adapter);

这部分工作正常,只是表明我送

This part is working fine, just showing that I sent

.putStringArrayListExtra("list", listItems);

活动B

adapter=new ArrayAdapter<String>(this,
R.layout.salelistitems,R.id.saleNotes,list);
setListAdapter(adapter);

ArrayList<String> al= new ArrayList<String>();
al = getIntent().getExtras().getStringArrayList("listItems");
if (al != null) 
{
listItems.add(al+"");
adapter.notifyDataSetChanged();

和如何我是从活动B发送到数据库

And how I send to database from Activity B

public void addNewsale(View view) {
    HashMap<String, String> queryValues =  new  HashMap<String, String>();
    final TextView saleNotes =(TextView)findViewById(R.id.saleNotes);
    queryValues.put("saleNotes", saleNotes.getText().toString());
    controller.insertsale(queryValues);
    this.callHomeActivity(view);
}

名单即将活动B在一排一起,在活动A每行有一个项目。
我不知道如何将列表视图项目分开。问题是saleNotes可以是1列表项或100 ListItems的。我不希望发送信息作为一个TextView,因为它会在数据库中去为[4辆3房1香蕉],而是我想

The List is coming to Activity B in one row all together, In Activity A each row had an item. I do not know how to separate the ListViews Items. The problem is saleNotes can be 1 ListItem or 100 ListItems. I don't want to send information as a TextView because it will go in database as [4 cars 3 houses 1 banana] but instead I want

4辆汽车

3的房子

1香蕉

谢谢OKS 16
    这从活动A将信息发送到正确的B

Thank You OKS 16 This sends the information from Activity A to B correctly

ArrayList<String> al= new ArrayList<String>();
al = getIntent().getExtras().getStringArrayList("list");
if (al != null){
for(String item:al){
listItems.add(item);
}
adapter.notifyDataSetChanged();}

但我怎么发送到数据库?它仍然是一个ListView。

But how do I send to database? It's still a ListView.

推荐答案

试试这个:结果
  为(字符串项:AL){结果
listitems.add(项目)结果
}

这篇关于如何ListView的内容发送到SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆