Android Question Converting to B4XPages

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I have a large project and looking into converting it to B4XPages.
The structure of the project is like this:
All screens are shown from Main by loading panel layouts (if screen is shown for the first time) or by making the required panel visible and making all other panels invisible.
All panels are setup in the designer.
There is a AppCompat actionbar with 4 menu groups. You can move between the menu groups by clicking a label on the actionbar.
Most screens (panels) are shown by clicking an actionbar icon.
Every menu group has as the last icon the hamburger icon and this will show the same Droppy menu:
https://www.b4x.com/android/forum/threads/droppy-dropdown-menu.81918/
I have a custom keyboard that is a layout on a panel, setup in the designer. This keyboard is shown or hidden by making the main panel visible or invisible.

A few questions how to convert:
1. Should I create a new B4XPage for every new screen (every panel) or should I load the layouts and make the panels visible or invisible all from B4XMainPage, so I have just one B4XPage?
2. I think I can do away with AppCompat and also Droppy and show the 4 different menu groups by just recreating the toolbar. Would there be a problem with that?
3. I don't think the custom keyboard should cause any problems, but it does add a lot of complexity and I may do away with that.

Any thoughts?

RBS
 

Attachments

  • FindPat.png
    FindPat.png
    151.3 KB · Views: 214

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I have a large project and looking into converting it to B4XPages.
The structure of the project is like this:
All screens are shown from Main by loading panel layouts (if screen is shown for the first time) or by making the required panel visible and making all other panels invisible.
All panels are setup in the designer.
There is a AppCompat actionbar with 4 menu groups. You can move between the menu groups by clicking a label on the actionbar.
Most screens (panels) are shown by clicking an actionbar icon.
Every menu group has as the last icon the hamburger icon and this will show the same Droppy menu:
https://www.b4x.com/android/forum/threads/droppy-dropdown-menu.81918/
I have a custom keyboard that is a layout on a panel, setup in the designer. This keyboard is shown or hidden by making the main panel visible or invisible.

A few questions how to convert:
1. Should I create a new B4XPage for every new screen (every panel) or should I load the layouts and make the panels visible or invisible all from B4XMainPage, so I have just one B4XPage?
2. I think I can do away with AppCompat and also Droppy and show the 4 different menu groups by just recreating the toolbar. Would there be a problem with that?
3. I don't think the custom keyboard should cause any problems, but it does add a lot of complexity and I may do away with that.

Any thoughts?

RBS

Add question 4:
Is it possible to make the B4XPage title (B4XPages.SetTitle(Me, cs) clickable?
Or otherwise, is it possible to add a menu item at the far left of the actionbar?
This is without using AppCompat.

RBS
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. I recommend creating a new page for each "screen".

2. You can use AppCompat with B4XPages, though you will lose the automatic up key icon.

4. The title can't be clicked but you can add a clickable icon in the top left corner. B4XPages will add an up indicator by default, however you can override it as demonstrated in B4XPage2 here: https://www.b4x.com/android/forum/threads/b4x-b4xpages-b4xdrawer.120246/#content
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
1. I recommend creating a new page for each "screen".

2. You can use AppCompat with B4XPages, though you will lose the automatic up key icon.

4. The title can't be clicked but you can add a clickable icon in the top left corner. B4XPages will add an up indicator by default, however you can override it as demonstrated in B4XPage2 here: https://www.b4x.com/android/forum/threads/b4x-b4xpages-b4xdrawer.120246/#content
Thanks, that does help.
With AppCompat you can add views to the actionbar. I take it this actionbar is an Android actionbar and the same object as the one accessed from B4XPages.
Is it not possible to add views to the actionbar if it is accessed via B4XPages?
Or is it possible to make an icon look like a label or button, holding text that is wider than high?

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Nothing special is needed. Same code as usual. The #Extends line should only be added to the activity module.
I think the only reason I would go with AppCompat would be to be able to add a view (eg a label or button) to the action bar that will hold text and allow a click action.
The idea of this is not to waste any space on the action bar by adding another menu item to move to the next menu group.
I think it might be little gain compared to the increased complexity adding AppCompat.
Is it possible to do a swipe of the action bar instead or use a long_click of a menu item to move to the next menu group?

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I had a go at that, but so far been unable to make the menu item wider than high:
for example, altering the MenuWithBadge example project:

B4X:
CartBitmap = TextToB4XBitmap("testing",20,Colors.Black,20,20,Typeface.DEFAULT,"CENTER").Resize(100,20,False)

Sub TextToB4XBitmap(strText As String, fFontSize As Float, iFontColour As Int, _
                     iWidth As Int, iHeight As Int, _
                     TF As Typeface, strAlignment As String) As B4XBitmap
 
    Dim bmp As Bitmap
    Dim cvs As Canvas
     
    bmp.InitializeMutable(iWidth * 100dip / 100, iHeight * 100dip / 100)
    cvs.Initialize2(bmp)
    Dim h As Double = cvs.MeasureStringHeight(strText, TF, fFontSize)
    cvs.DrawText(strText, bmp.Width / 2, bmp.Height / 2 + h / 2, TF, fFontSize, iFontColour, strAlignment)
     
    Return bmp.As(B4XBitmap)
 
End Sub

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I had a go at that, but so far been unable to make the menu item wider than high:
for example, altering the MenuWithBadge example project:

B4X:
CartBitmap = TextToB4XBitmap("testing",20,Colors.Black,20,20,Typeface.DEFAULT,"CENTER").Resize(100,20,False)

Sub TextToB4XBitmap(strText As String, fFontSize As Float, iFontColour As Int, _
                     iWidth As Int, iHeight As Int, _
                     TF As Typeface, strAlignment As String) As B4XBitmap
 
    Dim bmp As Bitmap
    Dim cvs As Canvas
    
    bmp.InitializeMutable(iWidth * 100dip / 100, iHeight * 100dip / 100)
    cvs.Initialize2(bmp)
    Dim h As Double = cvs.MeasureStringHeight(strText, TF, fFontSize)
    cvs.DrawText(strText, bmp.Width / 2, bmp.Height / 2 + h / 2, TF, fFontSize, iFontColour, strAlignment)
    
    Return bmp.As(B4XBitmap)
 
End Sub

RBS
OK, I can see now that if I don't set a bitmap, the menu item text will be as the title of the menu item.
So my previous post made no sense really. I can see now that I don't really need AppCompat.
All I need now is to be able to put the menu item that shows the title of the current page all the way at the left
of the actionbar.
Is there any way to do that?

RBS
 
Upvote 0
Top