Android Question SlideMenu is not working with some devices

jchal

Active Member
Licensed User
Longtime User
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
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:

jchal

Active Member
Licensed User
Longtime User
i am uploading a sample oriject to demonstrate this
 

Attachments

  • exmpleapp.zip
    11.9 KB · Views: 392
Upvote 0

jchal

Active Member
Licensed User
Longtime User
the problem with this is as soon as i run it it gives me a "B4A Example Stoped" and the program stops nothing on logs, i have tedet with wifi brige and with the usb cable
why it does that?
also b4a says when i load the project "this module id from a newer version and it migth run incorectly "
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The examples should work with v6.8.

the problem with this is as soon as i run it it gives me a "B4A Example Stoped" and the program stops nothing on logs, i have tedet with wifi brige and with the usb cable
why it does that?
Make sure to run your app in debug mode. If you don't see the error in the logs then switch to USB debug mode. There must be an error message there.
 
Upvote 0

jchal

Active Member
Licensed User
Longtime User
it is b4a 6.8
Make sure to run your app in debug mode. If you don't see the error in the logs then switch to USB debug mode. There must be an error message there.
i did this but in logs des not say anything i also used usb mode but the same nothing to guide me
 
Upvote 0

jchal

Active Member
Licensed User
Longtime User
in the file attached s is what i got when i Check the unfiltered logs. sorry it was a too big file so i had to zip it
 

Attachments

  • logs.zip
    40.3 KB · Views: 349
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
VFY: unable to resolve interface method 16564: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
VFY: replacing opcode 0x72 at 0x000a
VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
VFY: unable to resolve interface method 16566: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
VFY: replacing opcode 0x72 at 0x0006
Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
VFY: unable to resolve interface method 16570: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
VFY: replacing opcode 0x72 at 0x0008
Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
VFY: unable to resolve virtual method 549: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
VFY: replacing opcode 0x6e at 0x0004
Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
VFY: unable to resolve virtual method 571: Landroid/content/res/TypedArray;.getType (I)I
VFY: replacing opcode 0x6e at 0x000c
Exception while inflating <vector>
org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:720)
at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:653)
at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:615)
at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:734)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:367)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:197)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:711)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:81)
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:131)
at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:155)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:31)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:55)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:205)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:185)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at b4a.example.main.onCreate(main.java:33)
at android.app.Activity.performCreate(Activity.java:5326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.access$700(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5319)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40fd9930)
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{b4a.example/b4a.example.main}: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f020052
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.access$700(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5319)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f020052
at android.content.res.Resources.loadDrawable(Resources.java:2842)
at android.content.res.Resources.getDrawable(Resources.java:1521)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:374)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:202)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:711)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:81)
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:131)
at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:155)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:31)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:55)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:205)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:185)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at b4a.example.main.onCreate(main.java:33)
at android.app.Activity.performCreate(Activity.java:5326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
... 11 more
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:917)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:858)
at android.content.res.Resources.loadDrawable(Resources.java:2839)
... 30 more
Size of signalstrength parcel:56

Upload a small example which shoes the problem.
 
Upvote 0
Top