#Region Project Attributes
#ApplicationLabel: TestDrawer
#VersionCode: 1
#VersionName:
'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
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim NavDrawer As AHNavigationDrawer
'ListView inside Nav Drawer
Dim LV1 As ListView
'Panel holds NavDrawer's content
Dim pContent As Panel
'Amount to descend when drawer opens
Dim descendAmount As Int = 20dip
Dim WebView1 As WebView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
' Activity.LoadLayout("Main")
Activity.Title = "Slide out drawer"
'Initialize the navigation drawer.
NavDrawer.Initialize("NavDrawer", Activity, 240dip)
'We add the ListView to our NavigationPanel and set it up
LV1.Initialize("LV1")
NavDrawer.NavigationPanel.AddView(LV1, 0, 100dip, 100%x, 100%y)
NavDrawer.NavigationPanel.Color = Colors.ARGB(88,98,98,98)
LV1.AddSingleLine2("idiot", 0)
LV1.AddSingleLine2("happy", 1)
LV1.AddSingleLine2("smile", 2)
'Remove the fade on the background when drawer is open
SetScrimColor(NavDrawer, Colors.Transparent)
pContent.Initialize("pContent")
NavDrawer.ContentPanel.AddView(pContent, 0 ,0, 100%x, 100%y)
pContent.Color = Colors.Green
'Send behind the drawer
pContent.SendToBack
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub SetScrimColor(Nav As AHNavigationDrawer, Color As Int)
Dim r As Reflector
r.Target = Nav
r.Target = r.GetField("mNavDrawer")
r.RunMethod4("setScrimColor", Array As Object(Color), Array As String("java.lang.int"))
End Sub
'Animate on sliding the drawer
Sub NavDrawer_DrawerSlide (Position As Float, DrawerGravity As Int)
Dim Offset As Int = Position * descendAmount
pContent.Left = Offset
pContent.Top = Offset
pContent.Width = 100%x - 2 * (Offset)
pContent.Height = 100%y - 2 * (Offset)
End Sub
Sub lv1_ItemClick (Position As Int, Value As Object)
NavDrawer.CloseDrawer
Select Position
Case 0 : Test1
Case 1 : Test2
Case 2 : Test3
End Select
End Sub
Sub Test1
WebView1.Initialize("WebView1")
WebView1.ZoomEnabled = False
WebView1.LoadUrl("http://www.google.com.mm")
ProgressDialogShow("Loading ...")
pContent.AddView(WebView1, 0, 0, 100%x, 100%y)
End Sub
Sub WebView1_PageFinished (Url As String)
ProgressDialogHide
End Sub
Sub Test2
RemoveViews
pContent.LoadLayout("1.bal")
End Sub
Sub Test3
RemoveViews
pContent.LoadLayout("2.bal")
End Sub
'Correct Code It's work :D
Sub RemoveViews
Dim i As Int
For i=pContent.NumberOfViews-1 To 0 Step -1
pContent.RemoveViewAt(i)
Next
End Sub