2016-04-14 87 views
0

我有ArrayList中具有包括多個atitude經度不同ArrayList的多緯度經度

Log.d("try", "in the try"); 
        JSONObject jsonObj = new JSONObject(json); 
        Log.d("jsonObject", "new json Object"); 
        // Getting JSON Array node 
        matchFixture = jsonObj.getJSONArray(TAG_FIXTURE); 
        Log.d("json aray", "user point array"); 
        int len = matchFixture.length(); 
        Log.d("len", "get array length"); 
        for (int i = 0; i < matchFixture.length(); i++) { 
         JSONObject c = matchFixture.getJSONObject(i); 
         String matchId = c.getString(TAG_MATCHID); 
         Log.d("matchId", matchId); 


         // hashmap for single match 
         HashMap<String, String> matchFixture = new HashMap<String, String>(); 
         // adding each child node to HashMap key => value 
         matchFixture.put(TAG_MATCHID, matchId); 

         matchFixtureList.add(matchFixture); 


         HashMap<String,String>[] stockArr = new HashMap[matchFixtureList.size()]; 
         stockArr = matchFixtureList.toArray(stockArr); 
         for(HashMap<String,String> map : stockArr) 
          for(Map.Entry<String,String> entry : map.entrySet()){ 
           Log.d("debug", entry.getKey() + ","+ entry.getValue()); 
          } 
        } 

我不知道如何發送這MapActivity

public void setdaata(View view){ 


    Intent intent = new Intent(this, Registration.class); 
    String[] myStrings = new String[] {"test", "test2"}; 
    intent.putExtra("strings", myStrings); 
    startActivity(intent); 

} 

幫助我,請即如何發送這個並在MapActivity中使用

回答

0

您可以在活動之間發送ArrayList。但是,如果數組中的對象不是原始數據類型(如下面的MyObject),則必須實現Parcelable。

在當前活動

ArrayList<MyObject> list = new ArrayList<>(); 
list.add(new MyObject(..)); 
list.add(new MyObject(..)); 
list.add(new MyObject(..)); 

Intent intent = new Intent(CurrentActivity.this, TargetActivity.class); 
intent.putParcelableArrayListExtra("list", list); 
startActivity(intent); 

在靶活性

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    ... 
    Intent intent = this.getIntent(); 
    ArrayList<MyObject> list = (ArrayList<MyObject>)intent 
     .getParcelableArrayListExtra("list"); 
} 

編輯


  • 上述方法理想的用於切換AC時傳遞數據(您的實際問題) (您的實際問題)。
  • 如果你想訪問你的提取的json數據,從每個點的 應用程序,它必須存儲在您的設備上。
  • 簡單的存儲json數據的方法:合併gson library和共享首選項。檢查this link拿到想法
+0

先生,我可以有LatLog值的值可我收到的是,在該顯示特定位置的答案順序等其他活動,請其我最後一年的項目最後一個模塊 –

+0

我編輯的職位 – Blackkara