如何获得哈希表的ArrayList其他意图是什么? [英] how to get Hash table Arraylist to other intent?

查看:184
本文介绍了如何获得哈希表的ArrayList其他意图是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数组列表hashtbles。

I have hashtbles in array list.

 List<Hashtable<String, String>> info = new ArrayList<Hashtable<String, String>>();


 Hashtable<String, String> hm = new Hashtable<String, String>();
// Put elements to the map

hm.put("Read_Flag", s1);
hm.put("sms_received_id", s2);
hm.put("Sender_Id", s3);
hm.put("Sender_Name", s4);
hm.put("Patient_Name", s5);
hm.put("Received_Date", s6);
hm.put("Received_Text", s7);
hm.put("Received_Text_Full", s8);
hm.put("AttachmentFlag", s9);

// Get a set of the entries
Set<?> set = hm.entrySet();
// Get an iterator
Iterator<?> it = set.iterator();
// Display elements
while(it.hasNext()) {
Map.Entry me = (Map.Entry)it.next();
 // System.out.print(me.getKey() + ": ");
 // System.out.println(me.getValue());
}
//System.out.println(hm);

info.add(hm);

下面的信息包含我的哈希表。我怎样才能得到这个信息的对象到其他类/意图是什么?

here info contains my hashtables. how can i get this "info" object into other class/intent?

感谢你......

推荐答案

创建扩展序列化的getter 二传手> <$ C $为名单,其中,哈希表&LT;字符串,字符串&GT;&GT;清单

Custom.java

public class Custom implements Serializable{

    private static final long serialVersionUID = 4466821913603037341L;
    private List<Hashtable<String, String>> list;


    public List<Hashtable<String, String>> getList() {
        return list;
    }

    public void setList(List<Hashtable<String, String>> list) {
        this.list = list;
    }
}

传递到下一个活动。

List<Hashtable<String, String>> list = new ArrayList<Hashtable<String,String>>();

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

要检索下一个活动

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

这篇关于如何获得哈希表的ArrayList其他意图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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