Search code examples
androidradio-buttonandroid-tabhost

Radiobuttons to get the functionality of tabs


I am looking at something similar to tab widget.


Is it possible to use multiple buttons on same form and get the look and feel of a tab widget?

  • Basically, on a click of a button, a new form should be opened to fill up some values in same.

Functionality like a Tabhost

  • If true how to go for it

  • I looked many places and googled stuff ... I couldn't get a proper tutorial of any good source of information

Would be better radio buttons can be used !

I am a new bie so ... please go easy on me with answers :)


Solution

  • Short reply: you can implement the functionality using the Fragments, see http://developer.android.com/guide/components/fragments.html for details. Basically, you have to declare a layout like the one below

       (Vertical LinearLayout)
    +---------------------------+
    |      |      |      |      |
    |  B1  |  B2  |  B3  |  B4  |  (LinearLayout with 4 Buttons)
    |      |      |      |      |
    +------+------+------+------+
    |                           |
    |                           |
    |                           |
    |                           |
    |                           |
    |       FRAGMENTS           |
    |                           | (FrameLayout matching the parent)
    |          AREA             |
    |                           |
    |                           |
    |                           |
    |                           |
    |                           |
    +---------------------------+
    

    B1, B2, B3 and B4 are Buttons (or checkboxes, or whatever your GUI use to select the current view). Given a default view (Fragment) to be shown, each time you press a Button you change the Fragment in the Fragment area (resetting the Fragments back stack).