我有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 :(得分: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");
}
修改强>