iOS Question Segmented Control and various layouts

Discussion in 'iOS Questions' started by Rokiu86, Apr 22, 2015.

  1. Rokiu86

    Rokiu86 Member Licensed User

    Hi.

    Following this example:

    http://www.b4x.com/android/forum/threads/multiple-pages-example.48170/#content

    I understood the navigation between layouts.

    My target is have a SegmentedControl on the top of a layout with 4 Items. And for each Item charge a layout. My question is, Do I need have a SegmentedControl on the 4 layouts? or Can I have a only SegmentedControl and work with panels?

    For example:

    Code:
    SC as segmentedcontrol

    Sub SC_IndexChanged (Index As Int)
       
    select index
          
    case 0:
    panel1.visible=
    true
    panel2.visible=
    false
    panel3.visible=
    false
    panel4.visible=
    false
          
    case 1:
    panel1.visible=
    false
    panel2.visible=
    true
    panel3.visible=
    false
    panel4.visible=
    false
          
    case 2:
    .
    .
    .
          
    case 3:
    .
    .
    .
    end select

    end Sub
    In my opinion work with panel for this target is not the best option, because all the app have only a layout, but I dont know how can I do this with layouts.

    Any Idea or example?

    Thanks!!!!
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Consider using TabHostController instead. This is the more natural solution.

    With a segmented control you have two options:
    1. Use multiple panels.
    2. Use multiple pages with multiple segmented controls.

    Always try to avoid duplicating code.

    You can do something like:
    Code:
    Dim panels() As Panel = Array As Panel(panel1, panel2, panel3, panel4)
    ...

    'then you can easily change panels:
    'change to panel i (0 - 3):
    For x = 0 to panels.Length - 1
     panels(i).visible = x = i
    Next

    'or more "standard":
    If x = i Then panels(i).Visible = True else panels(i).Visible = False
     
  3. Rokiu86

    Rokiu86 Member Licensed User

    Thanks Erel.

    Sorry but What do you mean with "TabHostController"??
     
  4. Erel

    Erel Administrator Staff Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice