我在一个循环中添加说'n'微调器。但是当我运行我的代码时,只有最后添加的微调器可见。请在下面查看我的代码
Context context = this;
ArrayList<ArrayList<String>> list = new ArrayList<ArrayList<String>>();
ArrayList<String> hi = new ArrayList<String>();
hi.add("Test 1");
hi.add("Test 2");
list.add(hi);
ArrayList<String> hi1 = new ArrayList<String>();
hi1.add("Test 3");
hi1.add("Test 4");
list.add(hi1);
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle("Test App");
alert.setMessage("Testing");
for (int i = 0; i < 2; i++) {
final Spinner spinner = (Spinner) layout
.findViewById(R.id.spinner1);
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, list.get(i));
dataAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);
alert.setView(spinner);
}
alert.show();