Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create spinner with heading in it?

I am just thinking to create like below in spinner, but i am not sure how to make it work

 Fruits (heading unclickable) 
    Apple
    Mango
    Orange
 Cars (heading unclickable)
    BMW
    Lenova

Is that possible in Spinner or if you know any other method to create like this, then it would be great.

I am getting those details from the local database. Heading from one table and records from one table. I am looking for any example or solution.

Thanks for your help guys.

like image 308
vinothp Avatar asked May 24 '12 11:05

vinothp


People also ask

How do you name a spinner?

spinner. setPrompt("Title");

How do I add a spinner to my toolbar?

Adding spinner to app bar/ toolbar is very simple, you just need to create a XML file in res/menu/ folder and add a item like your over flow menu and spinner widget as item actionViewClass, rest in your java code. Spinner can be added to android actionbar/toolbar with many ways.

What is a spinner in programming?

Spinners provide a quick way to select one value from a set. In the default state, a spinner shows its currently selected value. Touching the spinner displays a dropdown menu with all other available values, from which the user can select a new one. You can add a spinner to your layout with the Spinner object.


1 Answers

After long time i found a way to do this. I achieved by combining a Button and Expandable ListView. What i have done is i created a button like spinner. OnClick I launched a popup Activity with Expandable list view in it by calling startActivityForResult() which returns the selected value. Finally i replaced the button text with the selected value.

If you looking for Expandable ListView Tutorial you can click below link.

(http://androidtrainningcenter.blogspot.co.uk/2012/07/android-expandable-listview-simple.html).

like image 55
vinothp Avatar answered Nov 09 '22 03:11

vinothp