0
有另一種方式做到這一點,我的意思是另一種方法或SPRATE方法,減少編碼,我想是做同樣的事情,但在diffreent方式安卓微調衣被合計方法用另一種方式
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.setOnItemSe
lectedListener(this);
extraextraextraextraextraextraextraextraextraextraextraextraextraextraextraextraextraextraextra