-1
至於儀式現在我只有一個微調有三個選項,我想要做的是如果選項一被選中,然後從list1中隨機選擇,選項2從列表2中選擇等等,我有一個小部分代碼寫得足以宣告微調和填充選擇,我從哪裏去?感謝提前!你如何從不同的名單中挑選一個微調器?
這裏是我的xml我的代碼:
<Spinner
android:id="@+id/alcohol"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:prompt="@string/prompt" />
然後,這是我的java文件:
setContentView(R.layout.activity_options);
// Set Alcohol Spinner
Spinner spinner = (Spinner) findViewById(R.id.alcohol);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.alcohol, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
謝謝大家!