2012-01-04 61 views

回答

0

我解決我的問題如下

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.println(hm); 

info.add(hm); 

//循環結束

2

創建類:

public class Maps implements Parcelable { 
    Map[] mapArray = new Map[10]; 

    public Map[] getMapArray() { 
     return mapArray; 
    } 

    public void setMapArray(Map[] mapArray) { 
     this.mapArray = mapArray; 
    } 

    @Override 
    public int describeContents() { 
     // TODO Auto-generated method stub 
     return 0; 
    } 

    @Override 
    public void writeToParcel(Parcel dest, int flags) { 
     // TODO Auto-generated method stub 

    } 

} 

然後在活動做接下來的事情就:

Intent intent = new Intent(); // create intent that call your another activity 
Maps maps = new Maps(); // create maps object. 
maps.getMapArray();  // mark your selected maps 
intent.putExtra("Maps", maps); // put key for your object 
startActivity(intent);// start your another activity. 

在另一個活動由「地圖」鍵得到這個對象,並使用它。

+0

其確定爲10哈希表,但我們如何能夠利用更多的哈希表? – Anand 2012-01-04 09:39:19

+0

創建方法,增加你的數組,並把更多的哈希表。 – Yahor10 2012-01-04 09:42:08

+0

如何在其他類/意圖中獲取該數據? – Anand 2012-01-04 10:06:18

相關問題