Android 向活动添加微调器
示例
在/res/values/strings.xml中:
<string-array name="spinner_options">
<item>Option 1</item>
<item>Option 2</item>
<item>Option 3</item>
</string-array>在布局XML中:
<Spinner
android:id="@+id/spinnerName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/spinner_options" />活动中:
Spinner spinnerName = (Spinner) findViewById(R.id.spinnerName);
spinnerName.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String chosenOption = (String) parent.getItemAtPosition(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {}
});
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短