如何从一个列表视图中需要的android例如添加项目到另一个列表视图上点击 [英] How to add an item from one listview to another listview on click in android example needed

查看:311
本文介绍了如何从一个列表视图中需要的android例如添加项目到另一个列表视图上点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能有人建议如何从我的列表视图中添加项目到另一个列表视图后,我单击该项目一个很好的例子吗?我有这样的烦恼,并希望我可以按照从开始到结束的例子。谢谢

Could someone recommend a good example of how to add an item from my listview to another listview after i click the item? i am having trouble with this and would like an example which i can follow from start to finish. Thanks

推荐答案

如果你的两个列表视图使用相同的适配器(即相同的数据类型),可以使用这样的:

If your two listview use the same adapter (ie the same data type) you can use something like this :

listView1.setOnItemClickListener(this);

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    datasListView2.add(valuesListView1.get(position));
    listView2.notifyDataSetChange();
}

在哪里dataListView1和dataListView1是你的价值观数组。

Where dataListView1 and dataListView1 are your values arrays.

这篇关于如何从一个列表视图中需要的android例如添加项目到另一个列表视图上点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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