Hey, i'm new to android development and i'm struggling to find some answers on the net related to this topic, if you could help that'd be incredible. Basically, like in the image above, i want to make a button or an edittext and a little arrow inside it. When that arrow is clicked i want it to open a little tab or another editext that gives options for users to click on and it transfers them to another activity. Thank you in advance
Asked
Active
Viewed 43 times
-1
-
All you have to do is add the extra text below it and set it's height to `0dp`. When the arrow is clicked, set the height to `wrap_content`. You can animate it to give it a good feel. Try this and add your code to the question if you still didn't get it. – Sujit Mar 17 '21 at 09:55
-
Have you been search for this ? https://www.google.com/search?q=spinner+android&safe=strict&sxsrf=ALeKk03nKGjwQpRIXUkUgKL_DgZOFXP2vw:1615974951524&source=lnms&tbm=isch&biw=1366&bih=657 – MrX Mar 17 '21 at 09:57
1 Answers
0
For example you can use two types of widgets:
- Spinner
- TextInputLayout with autocomplete textview
Spinner usage example:
<Spinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
and activity code:
String[] countries = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5"};
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, countries);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
possible example:
Small tutorial Solution with textInput - some documentation is here. Add widget to xml:
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
Small tutorial and fill it with some data from an activity.

Andrew
- 1,947
- 2
- 23
- 61