IM構建具有自毀圖像和我試圖從旋轉選擇的值傳遞給另一個類的應用程序在旋轉陣列傳遞一個選擇的值到另一個類的Android
final String titles[] = {"1 Second","2 Seconds", "3 Seconds","4 Seconds","5 Seconds","6 Seconds","7 Seconds", "8 seconds, "9 seconds", 10 seconds};
mSeconds = (Spinner) view.findViewById(R.id.secondsSpinner);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, titles);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSeconds.setAdapter(arrayAdapter);
mSeconds.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
int secondsToUse = position + 1;
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
// do nothing
}
});
我的意圖的方法:
Intent recipientsIntent = new Intent(getActivity(), RecipientsActivity.class);
recipientsIntent.putExtra("key1", titles);
startActivity(recipientsIntent);
如何將選定的值傳遞給另一個類?我的方法傳遞整個數組而不是選擇的項目。
你必須從你的示例代碼中傳遞什麼值? – ImMathan
@ImMathan用戶從微調器中選擇的值 – smithyy
[在android活動之間傳遞字符串數組]可能的副本(http://stackoverflow.com/questions/4429036/passing-string-array-between-android-activities) – moffeltje