Раскрывающийся список Android Spinner теряет элементы случайным образом во время прокрутки вверх / вниз - PullRequest
0 голосов
/ 23 апреля 2019

При прокрутке пользовательского вида прядильщика выпадающий элемент меню теряется.

Я перепробовал все принятые предложения, доступные здесь для подобных проблем типа, ничего не работало. вот код.

AndroidMnifest.xml

Android: hardwareAccelerated = "истина" андроид: largeHeap = "истинный"

SpinnerArray.xml

<string-array name="spinner_categories">
    <item>1</item>
    <item>2</item>
    <item>3</item>
    .
    .
    .
    <item>15</item>
    <item>16</item>
    <item>17</item>
</string-array>

<string-array name="spinner_categories2">
    <item>1</item>
    <item>2</item>
    <item>3</item>
    .
    .
    .
    <item>15</item>
    <item>16</item>
    <item>17</item>
</string-array>

custom_dropdown_layout.xml

<TextView 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layoutDirection="inherit"
    android:textAlignment="center"
    android:textColor="#3b7878" />

Fragment.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:shimmer="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".menus.Courses">

<LinearLayout
    android:id="@+id/Header"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:orientation="horizontal"
    android:gravity="center"
    android:padding="10dp">

    <Spinner
    android:id="@+id/mSpinner"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textAlignment="center"
    android:background="@drawable/bg_spinner"/>

</LinearLayout>

 <android.support.v7.widget.RecyclerView
    android:id="@+id/MenuView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/Header"
    android:scrollbars="vertical" />

 </RelativeLayout>

Fragment.java

private Spinner mySpinner;
private ArrayAdapter<CharSequence> mAdapter;
mySpinner = view.findViewById(R.id.mSpinner);

mAdapter = ArrayAdapter.createFromResource(Objects.requireNonNull(getContext()),R.array.spinner_categories, R.layout.custom_dropdown_layout);
mAdapter.setDropDownViewResource(R.layout.custom_dropdown_layout);
mySpinner.setAdapter(mAdapter);
mySpinner.setOnItemSelectedListener(this);


@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    Category = parent.getSelectedItem().toString();
}

@Override
public void onNothingSelected(AdapterView<?> parent) {
}

bg_spinner.xml

<shape android:shape="rectangle" android:useLevel="false">
<solid android:color="#00000000" />
<stroke android:width="1dp" android:color="#3b7878" />
</shape>
...