嗨,以下是动态创建微调器的代码,但我对如何将数据添加到生成的微调器感到困惑。提前谢谢。
LinearLayout rAlign = (LinearLayout)findViewById(R.id.lId);
LinearLayout spinnerHolder = new LinearLayout(getApplicationContext());
spinnerHolder.setOrientation(LinearLayout.HORIZONTAL);
spinnerHolder.setLayoutParams(
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
Spinner newSpinner = new Spinner(getApplicationContext());
newSpinner.setLayoutParams(
new Spinner.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
newSpinner.setAdapter(options);
rAlign.addView(spinnerHolder);
spinnerHolder.addView(newSpinner);