我sugggest您設置您的紡紗用一個簡單的ArrayAdapter
像這樣:
String[] selections = new String[] { "Selection 1", "Selection 2", "Selection 3", "Selection 4" };
ArrayAdapter<String> myAdapter = new ArrayAdapter<String>(mySpinner1.getContext(), android.R.layout.simple_spinner_item, selections);
myAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mySpinner1.setAdapter(myAdapter);
遵循所有6個紡紗同一個概念。然後當你獲取他們的價值觀,像這樣:
String value1 = mySpinner1.getSelectedItem().toString();
String value2 = mySpinner2.getSelectedItem().toString();
String value3 = mySpinner2.getSelectedItem().toString();
String value4 = mySpinner2.getSelectedItem().toString();
String value5 = mySpinner2.getSelectedItem().toString();
String value6 = mySpinner2.getSelectedItem().toString();
現在你可以在你的文本視圖根據需要串聯這些字符串,並顯示他們像這樣:
myTextView.setText(value1 + "," + value2 + "," + value3 + "," + value4 + "," + value5 + "," + value6);
希望有所幫助。玩的開心。
我有一個問題...我已經設置了ArrayAdapter類似於你所建議的...現在,我需要爲每個微調器單獨的ArrayAdapter?我想當我試圖製作一個適配器並讓每個微調器引用相同的ArrayAdapter時出現錯誤。感謝您的幫助 – user1055656
嗨,你需要一個新的適配器實例爲每個微調。每個微調器一個適配器。 –
不幸的是,一旦我嘗試設置我的TextView,我的程序就崩潰了。如果我試圖改變的TextView在不同的佈局上,這有什麼關係嗎? – user1055656