hi all
i am facing a problem with thefollowing example i am tryinh to implement , in some mobile phones i used to test the code it is working , in some others that i dscovered today it is not working for example in my sumsung duos it works correct or.... most correct.
in a samsung j3 it does not desplay the burger menu, it does the same on a samsung tablet i was testing it.
i am posting the code below and the class wicht is from an example i found in the forum.
it is a pity realy not to work as i quit understand the class and the code, if you can tell me what i do wrong i wil apriciate it
and the class is the following
also when a itred to run just the example it works on the j3 device but it does not let me clik the burger menu. it is stange but...... happens
what is the error? what i do wrong?
i am facing a problem with thefollowing example i am tryinh to implement , in some mobile phones i used to test the code it is working , in some others that i dscovered today it is not working for example in my sumsung duos it works correct or.... most correct.
in a samsung j3 it does not desplay the burger menu, it does the same on a samsung tablet i was testing it.
i am posting the code below and the class wicht is from an example i found in the forum.
it is a pity realy not to work as i quit understand the class and the code, if you can tell me what i do wrong i wil apriciate it
B4X:
#Region Project Attributes
#ApplicationLabel: myapp p
#VersionCode: 1
#VersionName: 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
Dim NavigationBar As StdActionBar
NavigationBar.Initialize("NavigationBar")
Dim NavBarHelper As StdActionBarHelper
NavBarHelper.Initialize
Dim MaterialMenu As MSMaterialMenu
MaterialMenu.Initialize("MaterialMenu")
Dim SlidingMenu As SlideMenu
SlidingMenu.Initialize(Activity, Me, "SlidingMenu", 0, 75%x)
Dim Button1,Button2 As Button
Dim Label1 As Label
Dim ListView1 As ListView
Dim webview1 As WebView
Dim Panel1 As Panel
Dim ImageView1 As ImageView
Private BannerAd As AdView
Private IAd As InterstitialAd
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Button1.Initialize ("Button1")
NavigationBarEvents
MaterialMenuEvents
SlidingMenuEvents
webview1.Initialize("webview1")
Label1.Initialize("Label1")
Activity.LoadLayout("MLayout")
Activity.Title = "test menus"
Label1.SetLayout (30%x,70%y,70%x,30%y)
ImageView1.SetLayout(0%x,0%y,100%x,100%y)
BannerAd.Initialize2("BannerAd", "ca-app-pub-", BannerAd.SIZE_SMART_BANNER)
Dim height As Int
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
'phones
If 100%x > 100%y Then height = 32dip Else height = 50dip
Else
'tablets
height = 90dip
End If
Activity.AddView(BannerAd, 0dip, 100%y - height, 100%x, height)
BannerAd.LoadAd
IAd.Initialize("iad", "ca-app-pub-")
IAd.LoadAd
End Sub
Sub ListView1_ItemClick (Position As Int, Value As Object)
webview1.RemoveView
Activity.AddView(webview1, 0, 0, 100%x, 90%y)
Select Value
Case "1A"
webview1.LoadUrl ("http://www.dom.com/1.html")
Case "2A"
webview1.LoadUrl ("http://www.dom.com/2.html")
Case "3A"
webview1.LoadUrl ("http://www.dom.com/3.html")
Case "4A"
webview1.LoadUrl ("http://www.dom.com/4.html")
Case Else
End Select
If IAd.Ready Then IAd.Show
End Sub
Sub mylist
Dim cs As CSBuilder
ImageView1.Visible=False
Label1.Visible=False
Panel1.SetLayout(0%x,0%y,100%x,100%y)
'ListView1.ScrollingBackgroundColor = Colors.DarkGray
ListView1.SetLayout(1%x,1%y,98%x,99%y)
ListView1.SingleLineLayout.Label.TextSize = 15
ListView1.SingleLineLayout.Label.Gravity = Gravity.LEFT
ListView1.AddSingleLine(cs.Initialize.Color(Colors.Black).Append("1.A").PopAll)
ListView1.AddSingleLine(cs.Initialize.Color(Colors.Black).Append("2.A").PopAll)
ListView1.AddSingleLine(cs.Initialize.Color(Colors.Black).Append("3.A").PopAll)
ListView1.AddSingleLine(cs.Initialize.Color(Colors.Black).Append("4.A").PopAll)
End Sub
Sub NavigationBarEvents
Activity.Title = "Προσευχητάρι"
NavigationBar.NavigationMode = NavigationBar.NAVIGATION_MODE_STANDARD
'NavigationBar.Icon = LoadBitmap(File.DirAssets, "logo.png")
End Sub
Sub MaterialMenuEvents
MaterialMenu.setScaleAndStroke(2,2)
MaterialMenu.Color = Colors.White
NavBarHelper.Icon = MaterialMenu.Drawable
MaterialMenu.TransformationDuration = 1000
End Sub
Sub SlidingMenuEvents
SlidingMenu.AddItem("item1", Null, 1)
SlidingMenu.AddItem("item2", Null, 2)
SlidingMenu.AddItem("item3", Null, 3)
SlidingMenu.AddItem("item4", Null, 4)
SlidingMenu.AddItem("item5", Null, 5)
End Sub
Sub SlidingMenu_Click(Item As Object)
MaterialMenu.animatePressedState("BURGER")
If Item = 1 Then
'ToastMessageShow("item 1 is MONDAY", False)
Activity.LoadLayout("MLayout")
mylist
End If
If Item = 2 Then
'ToastMessageShow("item 2 is TUESDAY", False)
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_VIEW, "market://search?q=pub:xxxxx")
StartActivity(Intent1)
End If
If Item = 3 Then
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_VIEW, "market://details?id=com.appp.zzzzz")
StartActivity(Intent1)
End If
If Item = 4 Then
ImageView1.Visible=True
Label1.Visible=True
End If
If Item = 5 Then
Dim result As Int
result = Msgbox2("close app;"," close app","yes","cancel","no", LoadBitmap(File.DirAssets, "ico.jpg"))
If result = DialogResponse.Positive Then
If IAd.Ready Then IAd.Show
Activity.Finish
Else
If IAd.Ready Then IAd.Show
End If
End If
BannerAd.Initialize2("BannerAd", "ca-app-pub-", BannerAd.SIZE_SMART_BANNER)
Dim height As Int
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
'phones
If 100%x > 100%y Then height = 32dip Else height = 50dip
Else
' 'tablets
height = 90dip
End If
Activity.AddView(BannerAd, 0dip, 100%y - height, 100%x, height)
BannerAd.LoadAd
End Sub
Sub NavigationBar_ButtonClicked
If MaterialMenu.State = "BURGER" Then
MaterialMenu.animatePressedState("X")
SlidingMenu.Show
Else
MaterialMenu.animatePressedState("BURGER")
SlidingMenu.Hide
End If
End Sub
Sub Activity_Click
If IAd.Ready Then IAd.Show
End Sub
Sub IAD_AdClosed
IAd.LoadAd 'prepare a new ad
End Sub
and the class is the following
B4X:
'SlideMenu Class module
'Version: 1.0
'Class module
Private Sub Class_Globals
Type ActionItem (Text As String, Image As Bitmap, Value As Object)
Private mSlidePanel As Panel
Private mBackPanel As Panel
Private mModule As Object
Private mEventName As String
Private mListView As ListView
Private mInAnimation As Animation
Private mOutAnimation As Animation
End Sub
'Initializes the SlideMenu object
' Activity - Pass a reference to the Activity here where the Slidemenu should be added to.
' Module - The calling Module. Pass the "Me" reference here
' EventNAme - EventName for the Click event
' Top - Top position of the Menu.
' Width - Width of the menu
Sub Initialize(Activity As Activity, Module As Object, EventName As String, Top As Int, Width As Int)
mModule = Module
mEventName = EventName
mSlidePanel.Initialize("mSlidePanel")
mListView.Initialize("mListView")
mListView.TwoLinesAndBitmap.SecondLabel.Visible = False
mListView.TwoLinesAndBitmap.ItemHeight = 50dip
mListView.TwoLinesAndBitmap.Label.Gravity = Gravity.CENTER_VERTICAL
mListView.TwoLinesAndBitmap.Label.Height = mListView.TwoLinesAndBitmap.ItemHeight
mListView.TwoLinesAndBitmap.Label.Top = 0
mListView.TwoLinesAndBitmap.ImageView.SetLayout(13dip, 13dip, 24dip, 24dip)
mListView.Color = Colors.Black
mInAnimation.InitializeTranslate("", -Width, 0, 0, 0)
mInAnimation.Duration = 200
mOutAnimation.InitializeTranslate("Out", Width, 0, 0, 0)
mOutAnimation.Duration = 200
Activity.AddView(mSlidePanel, 0, Top, Width, 100%y - Top)
mBackPanel.Initialize("mBackPanel")
mBackPanel.Color = Colors.Transparent
Activity.AddView(mBackPanel, -100%x, 0, 100%x, 100%y)
mSlidePanel.AddView(mListView, 0, 0, mSlidePanel.Width, mSlidePanel.Height)
mSlidePanel.Visible = False
End Sub
'Adds an item to the SlideMenu
' Text - Text to show in menu
' Image - Image to show
' ReturnValue - The value that will be returned in the Click event
Public Sub AddItem(Text As String, Image As Bitmap, ReturnValue As Object)
Dim item As ActionItem
item.Initialize
item.Text = Text
item.Image = Image
item.Value = ReturnValue
If Not(Image.IsInitialized) Then
mListView.AddTwoLinesAndBitmap2(Text, "", Null, ReturnValue)
Else
mListView.AddTwoLinesAndBitmap2(Text, "", Image, ReturnValue)
End If
End Sub
'Show the SlideMenu
Public Sub Show
If isVisible = True Then Return
mBackPanel.BringToFront
mSlidePanel.BringToFront
mBackPanel.Left = 0
mSlidePanel.Left = 0
mSlidePanel.Visible = True
mInAnimation.Start(mSlidePanel)
End Sub
'Hide the SlideMenu
Public Sub Hide
If isVisible = False Then Return
mBackPanel.Left = -mBackPanel.Width
mSlidePanel.Left = -mSlidePanel.Width
mOutAnimation.Start(mSlidePanel)
End Sub
Private Sub Out_AnimationEnd
mSlidePanel.Visible = False
End Sub
Private Sub mBackPanel_Touch (Action As Int, X As Float, Y As Float)
If Action = 1 Then
Hide
End If
End Sub
Private Sub mListView_ItemClick (Position As Int, Value As Object)
Dim subname As String
Hide
subname = mEventName & "_Click"
If SubExists(mModule, subname) Then
CallSub2(mModule, subname, Value)
End If
End Sub
'Check if the menu is currently visible
Public Sub isVisible As Boolean
Return mSlidePanel.Visible
End Sub
also when a itred to run just the example it works on the j3 device but it does not let me clik the burger menu. it is stange but...... happens
what is the error? what i do wrong?
Last edited: