我有三个包含值列表的微调器 我想用List首选项替换微调器
这是我的旋转课程
public static final int spinner1_op_val = 50;
public static final int spinner2_op_val = 10;
public static final int spinner3_op_val = 50;
Spinner spinner1 = (Spinner)findViewById(R.id.spinner1);
ArrayList<Integer> spinner1_options = new ArrayList<>();
for (i = 0; i <= spinner1_op_val; i += 1) {
spinner1_options.add(Integer.valueOf(i));
}
ArrayAdapter<Integer> dataAdapter_for_spinner1 = new ArrayAdapter<>(this, R.layout.support_simple_spinner_dropdown_item, spinner1_options);
dataAdapter_for_spinner1.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
spinner1.setAdapter(dataAdapter_for_spinner1);
spinner1.setSelection(4);
spinner1.setOnItemSelectedListener(this);
Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);
ArrayList<Integer> spinner2_options = new ArrayList<>();
for (i = 0; i <= spinner2_op_val; i++) {
spinner2_options.add(Integer.valueOf(i));
}
ArrayAdapter<Integer> dataAdapter_for_spinner2 = new ArrayAdapter<>(this,R.layout.support_simple_spinner_dropdown_item,spinner2_options);
dataAdapter_for_spinner2.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
spinner2.setSelection(2);
spinner2.setAdapter(dataAdapter_for_spinner2);
spinner2.setOnItemSelectedListener(this);
Spinner spinner3 = (Spinner) findViewById(R.id.spinner3);
ArrayList<Integer> spinner3_option = new ArrayList<>();
for (i = 0; i <= spinner3_op_val; i += 5) {
spinner3_option.add(Integer.valueOf(i));
}
ArrayAdapter<Integer> dataAdapter_for_spinner3 = new ArrayAdapter<>(this, R.layout.support_simple_spinner_dropdown_item, spinner3_option);
dataAdapter_for_spinner3.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
spinner3.setAdapter(dataAdapter_for_spinner3);
spinner3.setSelection(2);
spinner3.setOnItemSelectedListener(this);
这是我实现OnItemSelectedListener
的活动@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Editor editor;
switch (parent.getId()) {
case R.id.spinner1 /*2131492981*/:
myServer.counter1 = Integer.valueOf(parent.getItemAtPosition(position).toString());
editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
editor.putInt("counter1", myServer.counter1);
editor.apply();
return;
case R.id.spinner2 /*2131492983*/:
myServer.counter2 = (long) (Integer.valueOf(parent.getItemAtPosition(position).toString()) * 1000);
editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
editor.putLong("counter2", myServer.counter2);
editor.apply();
return;
case R.id.spinner3 /*2131492985*/:
myServer.counter3 = (long) (Integer.valueOf(parent.getItemAtPosition(position).toString()) * 1000);
editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
editor.putLong("counter3", myServer.counter3);
editor.apply();
return;
default:
return;
}
}
我希望使用列表首选项
执行相同的操作发布问题的额外文字 发布问题的额外文字 发布问题的额外文字 发布问题的额外文字 发布问题的额外文字