First_Explorer
First_Explorer

Reputation: 43

How to add an item from one listview to another listview on click in android example needed

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

Upvotes: 0

Views: 1141

Answers (1)

Rogue
Rogue

Reputation: 779

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();
}

Where dataListView1 and dataListView1 are your values arrays.

Upvotes: 1

Related Questions