开发者

Android Spinner Design Help

I'm working on an application where the user needs to select Year, Make, and Model for a vehicle. When the user selects a year, the list of makes is populated to only include those that exist for that year, and once the make is selected the list of models is populated based off the year and make.

I had initially used Spinners, but the problem is that Android Spinner's don't let you have an empty initial selection, and I don't want to load the make and model until a year is selected. I also don't want to include an item in the list that isn't a year.

Theres also an issue with Spinners where the onItemSelected() gets called when the Spinner is initalized, so its hard to determine if the system is selecting an item, or if a user is selecting an item. I only only to load the Makes after the user selects an item. I tried overriding the onItemSelected and using a custom adapter, but everytime the user selects an item, that method gets called twice, which seems odd t开发者_Go百科o me. Any solution I've came up with seems like a hack and doesn't feel polished.

I've looked online a lot and haven't found any solutions.

Is there a way to get the Spinner to work in this case, or is there a better design I can use for this?


"Spinners" or drop down menus work so much nicer on web pages with a mouse than they do on a mobile device with your finger...

You said the user chooses a year first, wouldn't it be better to have the user choose the make first? Pretty sure that's how it's usually done, nevertheless, maybe you could use an AutoCompleteTextView so that the user can type in the make (not having to choose it from a list of a billion makes) and it will narrow down the selection based off of the typing.

For the model you could possibly do the same, and then for the year, just let them enter the year... have a numpad come up (<EditText android:inputType="number" ... />) and it will be so much faster for the user than finding the year from a list of 60 years in a spinner.


I haven't tried any code to test this but my initial thoughts to solve this and still provide the spinners solution that you want is to populate the Make and Model spinners with a single dummy value and hide them. Then when the user selects a year, query your datastore for the relevant data, re-populate the Make spinner and make it visible. Then repeat the same for the Model spinner. You will also need to hide them if the user goes back and changes their initial selection in the Year spinner or the Make spinner.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜