Android Question StdViewPager trembles When trying to block access to one page .

hanoi ortega

New Member
Licensed User
Longtime User
I want to block users from use one StdViewPager page until they select a value.
When user select Position 2 and condition is false, I force to go back to position 1 . Sometimes it work, and sometimes screen trembles like crazy. May be this is not the best approach, but it be work ?no?.

Thank in adavance

#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime AsBoolean)
Dim height AsInt = CalculateHeight(True, True)
vp.Initialize("vp", 3, 100%x, height)
Activity.AddView(vp.AsView, 0, 0, 100%x, height)
'load the pages layouts
bar.Icon = LoadBitmap(File.DirAssets, "ic_action_user.png")
bar.NavigationMode = bar.NAVIGATION_MODE_TABS
bar.AddTab("Tab 1")
bar.AddTab("Tab 2")
bar.AddTab("Tab 3")
bar.ShowUpIndicator = True
bar.SelectedIndex = currentPage
Activity.Title = "This is the title"
bar.Subtitle = "This is the subtitle"
Activity.AddMenuItem3("", "mnuEdit", LoadBitmap(File.DirAssets, "ic_action_edit.png"), True)
Activity.AddMenuItem3("", "mnuNew", LoadBitmap(File.DirAssets, "ic_action_new.png"), True)
Activity.AddMenuItem3("", "mnuUndo", LoadBitmap(File.DirAssets, "ic_action_undo.png"), True)
CheckBox1.Checked = Page2CheckBoxStatus''' Page2CheckBoxStatus
End Sub
Sub bar_ButtonClicked
Log("bar button clicked")
End Sub
Sub CalculateHeight (TabsMode AsBoolean, SplitEnabled AsBoolean) AsInt
If100%x >= 480dipThen
Dim fix AsInt
If TabsMode Then fix = 48dip
If SplitEnabled Then fix = fix + 48dip
Return100%y - fix
End Sub
Sub VP_PageSelected (Position AsInt)
Ifbar.SelectedIndex <> Position Thenbar.SelectedIndex = Position
If Position = 2Then Page2worktoDo '''' Modified Code
End Sub
Sub bar_TabChanged(Index AsInt, STab AsStdTab)
Ifvp.currentPage <> Index Thenvp.ScrollTo(Index, False)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed AsBoolean)
currentPage = bar.SelectedIndex
End Sub
#Region "Modified Code"
Sub CheckBox1_CheckedChange(Checked AsBoolean)
Page2CheckBoxStatus = CheckBox1.Checked
End Sub
Sub Page2worktoDo
IfPage2CheckBoxStatus = TrueThen
'do something
ToastMessageShow ("doing something",True)
'back to Square one :(
vp.ScrollTo(1, False)
End Sub
#End Region


    14.7 KB · Views: 101
Last edited:

hanoi ortega

New Member
Licensed User
Longtime User
Erel, one hundred times thank you for professionalism and commitment. Like you suggested, I edited my first post including an example code (base in your own example :) ) and a zip file. The original project is to big to be posted, and to be one hundred percent honest, it is embarrassing how many errors I can write in just some lines of code. :)
Thank you again
Upvote 0