Reputation: 69
I'm trying to make a menu selectable, the menu works fine but when I try to select an item nothing happens, the menu stays fixed.
I want when I select an element that the value can be automatically displayed on the entry.
Here is my xml file with the autocomplete element :
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/order_transfert_amound_fixed_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/transfert_amount"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="15dp"
app:startIconDrawable="@drawable/ic_baseline_monetization_on_24">
<AutoCompleteTextView
android:id="@+id/order_transfert_amound_fixed_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/select_amount"
android:inputType="none"
/>
</com.google.android.material.textfield.TextInputLayout>
Here is the xml file fixed_amount_list.xml which contains the layout of my items :
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="?attr/textAppearanceSubtitle1"
android:clickable="true"
android:focusable="true"/>
And so my AmountActivity class which contains which allows me to apply the list:
public class AmountActivity extends AppCompatActivity {
private AutoCompleteTextView order_transfert_amound_fixed_textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_amount);
order_transfert_amound_fixed_textView = findViewById(R.id.order_transfert_amound_fixed_textView);
ArrayAdapter<String> adapter = new Adapter(this, R.layout.fixed_amount_list, AMOUNTS);
order_transfert_amound_fixed_textView.setAdapter(adapter);
}
private static final String[] AMOUNTS = new String[] {
"10.00", "15.00", "20.00", "25.00", "30.00"
};
}
The list is displayed perfectly but when I try to select an item, nothing happens. Does anyone have a solution. Thank you !
Upvotes: 1
Views: 314