AutoCompeleteTextView is not show ArrayList in dropDown kotlin using ViewBinding

AutoCompleteTextView is Replace with Spinner. AutoCompleteTextview inside TextInputLayout in Xml. Data Fill using Custom ArrayAdapter in AutoCompeleteTextView but Data is not Show in AutoComplete TextView dropdowm.

MainActivity.kt

val numberList = ArrayList<Serve>()
        numberList.add(Serve("101"))
        numberList.add(Serve("101/2"))
        numberList.add(Serve("201"))
        numberList.add(Serve("202/3"))
        numberList.add(Serve("205/1"))

  val adapterSeveNo = CustomArrayAdapter(this,serveNo)
            binding.autoCTVServeNo.setAdapter(adapterSeveNo)

  binding.autoCTVServeNo.setOnItemClickListener { adapterView, view, i, l ->
            val selectedItem = adapterView.getItemAtPosition(i).toString()

            Toast.makeText(this,selectedItem,Toast.LENGTH_LONG).show()
        }

activity.main.xml

<com.google.android.material.textfield.TextInputLayout
            android:id="@+id/tilListNumber"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="8dp"
            app:boxBackgroundMode="outline"
            app:endIconMode="clear_text"
            android:hint="Select Number.*"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/btnProductNext">

            <AutoCompleteTextView
                android:id="@+id/autoCTVServeNo"
                android:layout_width="match_parent"
                android:layout_height="60dp"

                android:paddingStart="10dp"
                android:paddingLeft="10dp"

                android:inputType="none"/>

        </com.google.android.material.textfield.TextInputLayout>

CustomArrayAdapter.kt

class CustomArrayAdapter( context: Context, val serveNo : ArrayList<Serve>) : ArrayAdapter<Serve>(context,0,serveNo) {

    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
        val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
        val binding = DropDownItemBinding.inflate(inflater)

        val ser = serveNo.get(position)

        binding.tvDropDown.text = ser.serveNo

        return binding.root
    }

}

drop_down_item.xml

<TextView
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/tvDropDown"
    android:padding="16dp"
    android:maxLines="1"
    android:ellipsize="end"
    android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1">

</TextView>

AutoCompleteTextview drop down is not data fill from ArrayList using ArrayAdapter in Viewbinding.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum