views:

712

answers:

3

Hey,

I am looking for a UI view that imitates the functionality of the Google Maps directions screen UI control where it allows the user to pick the type of directions allowed, either Car, Transit or Walking.

Like this --> http://snapplr.com/50rh

The widget is essentially three buttons laid out horizontally with rounded corners only on the left of the first and right of the thirdbutton.

I can't see a standard way to do this, although it seems like it would be a common widget. Is there some other standard way of presenting a multi-choice grouping in a horizontal layout as a "single" layout object.

Thanks for your help,

Wouter

+1  A: 

I am not aware of a button bar widget in the Android SDK. You would create one with ImageButtons in a LinearLayout, with custom backgrounds for all (to give the gloss-black look, to handle the varied sets of corners, and to handle the selected vs. not imagery). You would then need to add the toggling smarts, such that pushing one makes it selected and makes the others in the layout not selected.

If you wish to stick to simpler existing widgets, Spinner, RadioButton, or ToggleButton would be the most likely candidates.

CommonsWare
OK thank you for the information.. I will try it with ImageButtons. But I hope Google will release a widget for this so this would be easier to develop!Wouter
wouter88
A: 

I don't think there is a built-in way to do it. I can think of two ways to accomplish it. The first would be to create a custom style for the TabWidget. The second would be to create your own custom widget. Making a TabWidget style might be more flexible because you could easily come back and add or remove tabs and it would update accordingly. Making your own custom widget would give you much more control over how the widget looks and acts. So really you need to see what would be the best fit for what you're trying to do.

CaseyB
I haven't tried using `TabWidget` outside of actual tabs. It's an interesting concept!
CommonsWare
I just tried it and using the TabWidget outside of a TabHost doesn't work.
CaseyB
A: 

I'm actually in need of the exact same component. I just tried a simple gridview with buttons, but can't remove the border around the button to make it work properly.

Did you ever find a reasonable solution or is this going to be a write it yourself sort of thing?

Brill Pappin