嗨我想在运行时创建微调器,我的代码是,
RelativeLayout layout = (RelativeLayout) findViewById(R.id.linearLayout1);
final Spinner[] Sp = new Spinner[10];
Sp[count] = new Spinner(this);
RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(
(int) LayoutParams.WRAP_CONTENT,
(int) LayoutParams.WRAP_CONTENT);
param.leftMargin = 25;
param.topMargin = 50;
Sp[count].setPadding(5, 23, 5, 5);
Sp[count].setLayoutParams(param);
layout.addView(Sp[count]);
我有 String []数据如何在微调器下拉列表中添加其值?
希望你的建议
由于
答案 0 :(得分:1)
你可以像下面这样做
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, data);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Sp[count].setAdapter(adapter);