Ana*_*and 1 java android hashtable arraylist
我在数组列表中有哈希.
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);
Run Code Online (Sandbox Code Playgroud)
这里的信息包含我的哈希表.我怎样才能将这个"信息"对象变成其他类/意图?
谢谢...
创建一个延伸的类Serializable
与getter
setter
对List<Hashtable<String, String>> list
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;
}
}
Run Code Online (Sandbox Code Playgroud)
传递给下一个Activity.
List<Hashtable<String, String>> list = new ArrayList<Hashtable<String,String>>();
Custom custom = new Custom();
custom.setList(list);
intent.putExtra("myobj", custom);
Run Code Online (Sandbox Code Playgroud)
要在下一个Activity中检索
Intent intent = getIntent();
Custom custom = (Custom) intent.getSerializableExtra("myobj");
List<Hashtable<String, String>> list = custom.getList();
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3309 次 |
最近记录: |