开发者

how to display the selected items from a listview in the next listview

I have a custom listview. I have to select some items from this listview and display it in the next layout listview when a button click event is click开发者_StackOverflowed.

lv5=(ListView)findViewById(R.id.ListView05);
lv5.setAdapter(new ArrayAdapter<String>(this,R.layout.productselecttext,R.id.pstext,arr));

lv5.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if(view.findViewById(R.id.oi).getVisibility()==ImageView.VISIBLE){
            ImageView icon = (ImageView)view.findViewById(R.id.oi); 
            icon.setImageResource(R.drawable.vi); 
        }
    } 
 });

In this way I have selected using an imageview. How can I get only the selected items and display in another listview?


It all depends on what you call a selected item. We need some more code to understand how you "selected" items in the first listview.

But generally speaking, all you have to do is to build a new Adapter for the second list view that just lists the selected item. You could even recylcle the first adapter and the first view, just eliminating the items that are not selected from the adapter's list and calling

notifyDatasetChanged() 

on your first adapter to update your first list.

Regards, stéphane

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜