在將多個數據(在本例中爲三個數組(兩個int,一個字符串))發送到第二個活動頁面時存在問題。單個活動中的多個意圖
我不確定這是如何完成的。我想知道的是如何在一個Start Activity方法中發送這些數組,如果可能的話。我當前的代碼是:
public void onClickGoToTeamSummary(View view)
{
Intent intentTeamNames = new Intent(MainActivity.this, ResultsActivity.class);
Intent intentTeamPoints = new Intent(MainActivity.this, ResultsActivity.class);
Intent intentTeamGoals = new Intent(MainActivity.this, ResultsActivity.class);
intentTeamNames.putExtra("footballClubs", myTeams);
intentTeamPoints.putExtra("clubPoints", pointsAttained);
intentTeamGoals.putExtra("clubGoals", goalsScored);
startActivity(intentTeamPoints);
startActivity(intentTeamNames);
startActivity(intentTeamGoals);
}
我曾嘗試:
startActivity(intentTeamPoints, intentTeamNames, intentTeamGoals);
無濟於事。爲了幫助,我的下一個活動getIntent看起來是這樣的:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_results);
Intent intentClubNames = getIntent();
String[] club_names = intentClubNames.getStringArrayExtra("footballClubs");
Intent intentClubPoints = getIntent();
int[] team_points = intentClubPoints.getIntArrayExtra("clubPoints");
Intent intentTeamGoals = getIntent();
int[] club_goals = intentTeamGoals.getIntArrayExtra("clubGoals");
}
代碼本身的作品只提供一個startActivity被使用。我想知道如何通過一項活動將我的所有數組傳遞到第二個活動頁面,如果有人能幫助我的話。
我認爲這一個是在這裏明確解釋http://stackoverflow.com/questions/18195734/sending-multiple-intents-from-a-single-activity-to-another-activity – mahbubcsedu