截至目前,我所拥有的只是一个带有三个选项的微调器,我想做的是,如果选择了选项一,那么从 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);
谢谢大家!