menu to action bar

wheretheidivides

Active Member
Licensed User
Longtime User
So my project is nearly complete. I uploaded to google play store. There's just 1 or 2 things left. 1 of those is the action bar. I have a menu that pops up with settings. I see there is some action bar now. So how do I convert it over. Is there a quick and easy way to do this? I don't need anything fancy, just a click with these to pop up. I read erel's info on a manifest editor which I have no idea what that is. I saw a add-on AHactionbar. The thing is I have no idea of how to call the commands. ANy help? and please, remeber the B in BASIC stands for beginners. All I need is to change the menu below to a action bar.
Thanks


B4X:
'---------------------------------------------
'Menu
   Activity.AddMenuItem("Title Screen","Help") 'top left
   Activity.AddMenuItem("Instructions","Help") 'top center
   Activity.AddMenuItem("Return To Game","Help") 'top right
   
   Activity.AddMenuItem("Zero Stats","Help") 'bottom left
   Activity.AddMenuItem("Debug (On/Off)","Help") 'bottom center
   
   Activity.AddMenuItem("Continuation Bet (On/Off)","Help") 'more 1
   Activity.AddMenuItem("Double/Triple Down (On/Off)","Help") 'more 2
   Activity.AddMenuItem("Split 2 Card Pairs (On/Off)","Help") 'more 3
   Activity.AddMenuItem("Sound Effects (On/Off)","Help") 'more 4

'---------------------------------------------
 

wheretheidivides

Active Member
Licensed User
Longtime User
Make sure that the following line is included in the manifest editor:
B4X:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
This is the default for new projects. On older projects you will need to manually add the targetSdkVersion.



I did that and when i press the menu key it pops up in along verticle list. Before it was 2 rows of 3.

But here's the problems on the 7" zeki tablet.
1) whenever I press any of the menu actions, the program crashes. It goes back to the desktop. Now the first 3 choices bring a panel to the front for instructions. It' the others where it has a message pop up to ask if you want to do something where it crashes.


2) the buttons that were solid when enabled and visible are now transparent. they are just slightly darker than the not eneabled and visible buttons.
3) I have popups with message for on and off. It switched the location of on and off so they are backwards from phone,

My samsung galaxy s i epic 4g still looks good. The buttons are the same translucent (which is dark) and the menu looks like the old menu.

So is there more code that need to be done that I am missing (I feel a 'read the tutorial' coming up).

thanks in advance. I have the program 99% done and it's on google play for download as we speak.
 
Last edited:
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
OK, so I added the reflection to the correct folder and added clsaction bar to the prohect as another module, and now it doesn't crash on my zeki tablet. However, the buttons still look weird. When enabled, they barely look darker than when they are not enabled. However on the old android phone they all look good. The transparency of enabled buttons look solid.

So is this a android thing or a programming thing?
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
This is how the new style looks (also the buttons). You can also add menu items directly to the action bar by using AddMenuItem3.

Which error did you get? You should check the logs.


I changed the buttons to use icons i did in photoshop. 2 of them. 1 at 100% tansparency and 1 at 30% for enable and disable. Looks good.


As far as the error goes i am still having it on the tablet. On the phone it's fine. It started when you told me to change manifest editor. As far as the error, I am still looking at how to find the error log. I looked in every dircetory and nothing.
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
I connected tablet to b4a. clicked connect under the logs tab. I ran the program. I clicked on the menu. The message popup came. I clicked to turn it on and it crashed. The error is 'unfortunelty low-joe has stopped'. here is log. This does not happen on samsung galaxy s epic 4 g with 2.36 gingerbread. This crashed on 7" zeki tablet with android 4.0.4. It started when you had me change the manifest editor to

Manifest destiny script
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

Log from running app
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.RuntimeException: MotionEvent { action=ACTION_UP, id[0]=0, x[0]=126.7027, y[0]=127.45819, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=84376868, downTime=84376629, deviceId=2, source=0x1002 } recycled twice!
   at android.view.MotionEvent.recycle(MotionEvent.java:1660)
   at android.view.ViewRootImpl.finishMotionEvent(ViewRootImpl.java:2942)
   at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2933)
   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2492)
   at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:870)
   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2501)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4424)
   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:784)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
   at dalvik.system.NativeStart.main(Native Method)
 
Last edited:
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
I THINK i found the problem. The 'dialogs 2.80' library was not checked. However, instead of crashing everytime the dialog box pops up, it crashed 1 out of 20 times.
 
Last edited:
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
I am using B4A 2.22 and reflection 2.20 is checked in library. I don't know how to use it though.

Here is activity create menu
B4X:
'Menu
   Activity.AddMenuItem("Title Screen","Help") 'top left
   Activity.AddMenuItem("Instructions","Help") 'top center
   Activity.AddMenuItem("Return To Game","Help") 'top right
   
   Activity.AddMenuItem("Zero Stats","Help") 'bottom left
   Activity.AddMenuItem("Practice (On/Off)","Help") 'bottom center
   
   Activity.AddMenuItem("Allow Cont' Bets? (Y/N)","Help") 'more 1
   Activity.AddMenuItem("Allow Double/Triple? (Y/N)","Help") 'more 2
   Activity.AddMenuItem("Allow Splitting Pairs? (Y/N)","Help") 'more 3
   Activity.AddMenuItem("Sound Effects (On/Off)","Help") 'more 4

help
B4X:
Sub Help_Click
'---------------------------------------------
'Menu
Select Sender
   Case "Title Screen"
      'turn on panel
         Panel1.Visible=True 

      'turn off other panels
         Panel3.Visible=False
         Panel4.Visible=False
            
   Case "Return To Game"
      Panel1.Visible=False
      Panel3.Visible=False
      
      If DebugOn = True Then
         Panel4.Visible=True
      Else If DebugOn=False Then
         Panel4.Visible=False
      End If
      
                  
   Case "Zero Stats"
      Zero 'Subroutine

   Case "Instructions"
      Instruct 'Subroutine
         
   Case "Practice (On/Off)"
      Bug 'Subroutine
      
   Case "Allow Cont' Bets? (Y/N)"
      ContBet ' Subroutine
            
   Case "Allow Double/Triple? (Y/N)"
      DDTD 'SUBROUTINE

   Case "Allow Splitting Pairs? (Y/N)"
      SplitThem'SUBROUTINE
      
   Case "Sound Effects (On/Off)"
      Sound'SUBROUTINE
      
End Select
'-------------------------------------
End Sub

Sub Button_Click
'---------------------------------------------
'menu
   Dim Send As Button
   Send = Sender
   
   Select Send.Tag
      Case "1"
         Panel1.Visible=False
      Case "2"
         Panel71.Visible=False
      Case "3"
         '
      Case "4"
         '
      Case "5"
         Panel3.Visible=False
      Case "6"
         '
   End Select
'-------------------------------------
End Sub

1 of the subroutines
B4X:
Sub Bug
'-------------------------------------
   Result = Msgbox2("Turn practice mode on or off?", "Practice", "On", "", "Off", LoadBitmap(File.DirAssets, "red deck-verticle.bmp"))
   
   If Result = DialogResponse.Positive Then
      Panel4.Visible=True
      LabelInfoBar.Text="Practice mode is now turned ON."
      DebugOn = True
   Else If Result = DialogResponse.Negative Then
      Panel4.Visible=False
      LabelInfoBar.Text="Practice mode is now turned OFF."
      DebugOn = False
   End If
'-------------------------------------
End Sub

more of the subs that crashes
B4X:
Sub ContBet
'-------------------------------------
   Result = Msgbox2("Allow 'Continuation' bets with all back-to-back cards of same rank for table minimum bet?", "Continuation Bet", "Yes", "", "No", LoadBitmap(File.DirAssets, "red deck-verticle.bmp"))
   
   If Result = DialogResponse.Positive Then
      ContOn=True
      LabelInfoBar.Text="Continuation bets are now ALLOWED."
      LabelC2.text ="Y"
   Else If Result = DialogResponse.Negative Then
      ContOn=False
      LabelInfoBar.Text="Continuation bets are now NOT ALLOWED."
      LabelC2.text ="N"
   End If
   
'-------------------------------------
End Sub
Sub DDTD
'-------------------------------------
   Result = Msgbox2("Allow 'Double Down' & 'Triple Down' bets on first card for 2x or 3x current bet?", "Double/Triple", "Yes", "", "No", LoadBitmap(File.DirAssets, "red deck-verticle.bmp"))
   
   If Result = DialogResponse.Positive Then
      DownOn=True
      LabelD2.text ="Y"
      LabelInfoBar.Text="Double & triple downs are now ALLOWED."
   Else If Result = DialogResponse.Negative Then
      DownOn=False
      LabelD2.text ="N"
      LabelInfoBar.Text="Double & triple downs are now NOT ALLOWED."
   End If
'-------------------------------------
End Sub
Sub SplitThem
'-------------------------------------
   Result = Msgbox2("Allow first 2 cards of same rank to be able to split?", "Split Pairs", "Yes", "", "No", LoadBitmap(File.DirAssets, "red deck-verticle.bmp"))
   
   If Result = DialogResponse.Positive Then
      SplitOn=True
      LabelS2.text ="Y"
      LabelInfoBar.Text="Splitting of pairs is now ALLOWED."
   Else If Result = DialogResponse.Negative Then
      SplitOn=False
      LabelS2.text ="N"
      LabelInfoBar.Text="Splitting of pairs is now NOT ALLOWED."
   End If
'-------------------------------------
End Sub
Sub Sound
'-------------------------------------
   Result = Msgbox2("Do you want the sound on or off?", "Sound Effects", "On", "", "Off", LoadBitmap(File.DirAssets, "red deck-verticle.bmp"))
   
   If Result = DialogResponse.Positive Then
      SoundOn = True
      LabelInfoBar.Text="Sound effects are now turned ON."
   Else If Result = DialogResponse.Negative Then
      SoundOn = False
      LabelInfoBar.Text="Sound effects are now turned OFF."
   End If
'-------------------------------------
End Sub
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
Low-Joe

If you want to try out the game yourself, it is on google play as 'low-joe'. It's up ther for free for now. The only thing left to do is to play it and find any bugs.
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>


so this just makes the program crash on the tablet with newer OS. I just took it out and went backto old menu where it doesn't crash.
 
Upvote 0
Top