0

I have an android application with a drop down list which have left and right icon, I try to use spinner with left and right drawable, but does not work, what I need is look like below where user can only enter (select) from the list, which mean autocomplete text is not useful, also dropped list does not contain image, How can I achieve that?

Edit text with left and right drowable

Ali A. Jalil
  • 873
  • 11
  • 25
  • Check out custom spinner. Lots of tutorial and example. https://stackoverflow.com/questions/16694786/how-to-customize-a-spinner-in-android – tiborK Nov 19 '19 at 16:36
  • @tiborK thanks for your reply. I have multi spinner with different images, are I need to create spread file for each one of them? are there any way to create one and change it's image each time? – Ali A. Jalil Nov 19 '19 at 16:38
  • Check out this tutorial. I think this is what you are looking for. It's in Java but you can get the logic of how to create it in kotlin and customize it to your needs. https://www.youtube.com/watch?v=GeO5F0nnzAw – tiborK Nov 19 '19 at 19:01
  • I don't want image to appear in dropped list, just in input. – Ali A. Jalil Nov 20 '19 at 06:11

2 Answers2

1

So after better understanding your idea, this is the steps you need.

  1. create a custom adapter (this should take the list of string you want to display and the list of icons )
  2. list item is one edit text like

    <EditText
    ...     
    android:drawableLeft="@drawable/my_icon" />
    
  3. create your spinner and set the adapter

    Spinner sp = findViewById(R.id.spinner);
    sp.setAdapter(your custom adapter)
    
  4. add the item selected listener and you are done.

More info on adapters

tiborK
  • 385
  • 1
  • 6
0

You need to use a custom spinner With Image And Text and a card view back ground for spinner. check this link how to add drop-down menu spinner. https://stackoverflow.com/a/24422359/2546742

Praveen
  • 430
  • 3
  • 11