没有单选按钮,微调按钮按钮、单选

2023-09-04 03:41:34 作者:装逼遭雷劈从头劈到逼@

如何从微调按钮删除单选按钮,仅使用的themes.xml?施加其他的风格后,我可以删除它,但我不能在默认情况下从的themes.xml删除此单选按钮。

How to remove Radio button from spinner BUTTON, using only Themes.xml? I can remove it after applying an other style, but I can't to remove this radio button from Themes.xml by default.

<style name="My.Theme.Spinner" parent="android:Widget.Spinner">
    <item name="android:background">@drawable/spinner_bg</item>
    <item name="android:clickable">true</item>
    <item name="android:spinnerMode">dialog</item>
    <item name="android:checkedButton">@null</item>
    <item name="android:checkable">false</item>
</style>

主题

    <style name="My.Theme" parent="@android:style/Theme">
        <item name="android:spinnerStyle">@style/My.Theme.Spinner</item>
    </style>

原装适配器(在项目单选按钮)

ORIGINAL adapter (with radio buttons in items)

new ArrayAdapter<String>(getActivity(), R.layout.spinner_item,
            getResources().getStringArray(R.array.registrationIds));

更新适配器(不含无线):

Updated Adapter (without radio):

new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.registrationIds));

请注意:微调的项目应该有一个单选按钮。微调按钮应该没有收音机。

Note: Spinner items should have a radio buttons. Spinner button should be without radio.

fragment.xml之

Fragment.xml

<Spinner
                android:id="@+id/spinner"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:paddingLeft="@dimen/small_content_padding"/>

请参阅我的问题:

See my issue:

推荐答案

您需要添加viewResourceid在createresource只有IE浏览器,如下所示。

You need to add viewResourceid in createresource only i.e., as follows..

如果要创建一个使用资源的数组。

if you are creating with resource array.

adapter = ArrayAdapter.createFromResource(ActivityName.this,Your values resource id here,android.R.layout.simple_spinner_item); 
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

如果要创建一个使用字符串[]对象,然后它会是如下。

if you are creating with string[] Objects then it'll be as follows..

ArrayAdapter<String> adapter = new ArrayAdapter<String>(ActivityName.this,  android.R.layout.simple_spinner_item, String[]namehere);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);