English 中文(简体)
2台Spinners,1台有无线电台,1台
原标题:2 Spinners one has radio buttons in the list and one doesnt

我正在安乐施。 我有2个pin子,与另外几个EditText在一起。 顶端的Spinner在名单上每个项目都显示无线电台。 第二种是没有的,而第二个Spinner的每行比第一个Spinner小得多。 这里是我的xml代码。

<Spinner
    android:id="@+id/new_type"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/list_prompt"
android:textColorHint="@android:color/white" />
<Spinner
android:id="@+id/new_course"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/enter_course"
    android:textColorHint="@android:color/white" />

这里是我的 j。

Spinner spinner = (Spinner) findViewById(R.id.new_type);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
    R.array.type_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);

Spinner cSpinner = (Spinner) findViewById(R.id.new_course);
ArrayAdapter<CharSequence> cAdapter = ArrayAdapter.createFromResource(this, 
    R.array.course_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cSpinner.setAdapter(cAdapter);

2个轴心几乎完全相同,我必须说明为什么在2个轴心之间有如此大的差别。 非常感谢任何帮助。

最佳回答

You are declaring a new ArrayAdapter with the name cAdapter but one line below you are setting the drop down view resource 页: 1 the previous adapter.

修改此行:

adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cSpinner.setAdapter(cAdapter);

页: 1

cAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cSpinner.setAdapter(cAdapter);

固定:

问题回答

暂无回答




相关问题
How to set Spinner default value to null?

I m trying to get a Spinner to load up with no selected value. Once the user selects a value it then takes them to another page. This is proving to be a problem because at present, the page just ...

Accessing objects dynamically created with an adapter

I ve created a dynamic ListView with TextViews and Spinners, using a SimpleAdapter and a ViewBinder. How can I access a Spinner value after the user had selected it? I think I need to create ...

How to show divider between spinner items?

I using listviews and expandedviews that has dividers and I can set them but on spinner its looks like it is no divider between items. Someone that has a idea of how to fix this?

热门标签