0

I tried to find the answer for this and found something like nested spinner. I understood the concept of nested spinner where we take the values from one spinner and use it inside the child spinner to inflate the values to be shown.

But how can I have something like a Spinner inside that Spinner dropdown itself. Instead of a Textview to be shown I want to show a Spinner and this Spinner will have different values.

Image for reference : enter image description here

As you can see from this image there is a Spinner called as "Choose Profile" and it has 3 values. And all these values are not just simple textviews but another spinners. I would like to understand what is the approach to make something like this.

oyeraghib
  • 878
  • 3
  • 8
  • 26

1 Answers1

0

Well, first of all, I would like to try to dissuade you from doing this. From a user experience perspective, it's horrendous. Spinners opening on top of other spinners will get very confusing very quickly.

And from the programming perspective, it's a pain as well. You would need to create a custom adapter for your spinner, where every view has a spinner in it. And that means that you would have to track nested spinners returning their values. The code will become very confusing, and maintaining it later will be even worse.

Having said all that, if you want to do it anyway, you'll need to create a custom Adapter for your main spinner. Inside each custom view (or "row"), you would create a spinner as well, so every "row" would have another spinner in it. You can see how to create custom adapters here for the general process of doing it.

Edit: A better UI approach would probably be to use just a dialog with a ListView in it. You can still use a Spinner for the initial menu, but when the user chooses one of the options, it'll pop up a list of options for them to pick. Since it's a Dialog, it'll be centered on the4 screen, with the rest of the UI behind a scrim

user496854
  • 6,461
  • 10
  • 47
  • 84
  • Thanks for that answer. But I would also like to know what is the other alternative to solve this kind of thing. Like the Image I have shared, what is the way to tackle it (without nested Spinners) – oyeraghib Sep 13 '22 at 09:04
  • That image shows nested spinners, so I'm not sure what you're asking. To be clear, I'm saying that what's shown in the image is a terrible UI design, and should not be implemented – user496854 Sep 13 '22 at 16:16
  • Do you know of any better UI approach for such mechanism ? Basically I need a view, and on click of that view I need to show three items (they have fixed length of 3) as shown in image. And each single item have it's own list. If not spinner, what do you think is a more better UI for it? – oyeraghib Sep 13 '22 at 18:19
  • I'm updating my answer... – user496854 Sep 13 '22 at 19:48