how to get Hash table Arraylist to other intent?

前端 未结 4 1067
Happy的楠姐
Happy的楠姐 2020-12-10 00:21

I have hashtbles in array list.

 List> info = new ArrayList>();


 Hashtable<         


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 01:01

    Create a class that extends Serializable with getter setter for the List> list

    Custom.java

    public class Custom implements Serializable{
    
        private static final long serialVersionUID = 4466821913603037341L;
        private List> list;
    
    
        public List> getList() {
            return list;
        }
    
        public void setList(List> list) {
            this.list = list;
        }
    }
    

    To pass to next Activity.

    List> list = new ArrayList>();
    
    Custom custom = new Custom();
    custom.setList(list);
    intent.putExtra("myobj", custom);
    

    To retrieve in next Activity

    Intent intent = getIntent();
    Custom custom = (Custom) intent.getSerializableExtra("myobj");
    List> list = custom.getList();
    

提交回复
热议问题