首页 > 解决方案 > 使用 ArrayAdapter 关闭 Android Spinner 会丢失项目填充

问题描述

我有一个问题,如果我使用基本的 ArrayAdapter 在微调器中显示项目,如果我打开微调器,这些项目上的所有间距都会丢失,通过在其外部点击将其关闭,然后再次打开它。看起来像颜色等其他属性仍然保持不变。

这是我创建微调器的方式:

binding.fragmentTypeSpinner.setAdapter(new ArrayAdapter<>(mContext,
                R.layout.item_simple_spinner,
                typeArray));

item_simple_spinner.xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/item_simple_text_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorTransparent"
    android:textSize="17sp"
    android:padding="10dp" />

乍一看如何: 乍一看如何

它的外观如何:在此处输入图像描述

我也尝试了基本的 android 微调器项目布局,但仍然没有骰子。这种情况以前发生在其他人身上吗?我搜索了但想不出很多。

标签: androidspinnerandroid-arrayadapter

解决方案


推荐阅读