Is it possible to put a spinner in function to another spinner just as an image?

Asked

Viewed 33 times

0

I’m new to Android Studio and wanted to make two spinners. One that would be for example cars, motorcycles and when selected the option the other appeared the images with the names of cars ( case selected cars ) or motorcycles ( case selected bikes)

  • 1

    Question answered. The focus of the site is to clarify questions related mainly to errors. When you are doing and you are in doubt put the code you did and the error you present and more people will help you :D

1 answer

1

First situation - fill in the second spinner after selecting the information in the first: For this you can use the Onitemselectedlistener(). It would be something like this:

spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
        //seu código aqui }

    @Override
    public void onNothingSelected(AdapterView<?> parentView) {
        //seu código aqui  }

});

Second situation - make the spinner appear images: You will need to make a custom layout for your spinner. There is a tutorial on this link to make it easy for you: https://www.codingdemos.com/android-custom-spinner-images-text/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.