Android 首选项菜单(单击时更改数组 ID)
我有 2 节课。一个带有旋转器的类和一个偏好类。微调器使用 strings.xml` s1 = (Spinner) findViewById(R.id.spinner1); 中的数组进行设置;
ArrayAdapter adapter1 = ArrayAdapter.createFromResource(
this, R.array.height_array, android.R.layout.simple_spinner_item);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(adapter1);`
第二类是带有ListPreference的首选项类(认为它是一个ListPreference) /有点像旋转器。如果您单击它并从 ListPreference 中选择任何项目,我希望微调器使用另一个数组。将 R.array.height_array 更改为 R.array.height2_array 或类似的内容。可能的 ?
i got 2 classes. A class with a spinner in it and a preference class. The spinner is set up with a array from strings.xml` s1 = (Spinner) findViewById(R.id.spinner1);
ArrayAdapter adapter1 = ArrayAdapter.createFromResource(
this, R.array.height_array, android.R.layout.simple_spinner_item);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(adapter1);`
The second class is the preference class with a ListPreference(think it is a a ListPreference)
/kind of a spinner. If u click it and select any of the items from the ListPreference i want the spinner to use another array. Change R.array.height_array to R.array.height2_array or something like that. Possible ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这样的东西应该有效。如果需要 2 个以上的选择,请使用更多的 if
yes, something like this should work. If you need more than 2 choices, use more ifs