The same way as you added it to your Mainactivity.How can i add menu in toolbar in each activity?
I tried it but it not work. The Activity_CreateMenu was not calledThe same way as you added it to your Mainactivity.
Where is the project showing the problem?I tried it but it not work
#Region Project Attributes
#ApplicationLabel: Food Box
#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
#Extends: android.support.v7.app.AppCompatActivity
#BridgeLogger: true
Sub Process_Globals
Private badge As Int
Private cartBitmap As Bitmap
Dim manager As PreferenceManager
End Sub
Sub Globals
Dim TextScale As Float
Dim TextScale2 As Float
Private ACToolBarLight1 As ACToolBarLight
Private ToolbarHelper As ACActionBar
Private sm As SlidingMenu
Private ListView1 As ListView
Private Button1 As Button
' Private EditTextPassword As EditText
' Private PanelForPassword As Panel
' Private Label4 As Label
' Private EditTextUsername As EditText
' Private PanelForUsername As Panel
' Private Label3 As Label
' Private EditTextContactNo As EditText
' Private PanelForContactNo As Panel
' Private Label2 As Label
' Private Label1 As Label
' Private EditTextName As EditText
' Private PanelForName As Panel
Private EditTextName As EditText
Private PanelForName As Panel
Private EditTextEmail As EditText
Private PanelForEmail As Panel
Private EditTextPassword As EditText
Private PanelForPassword As Panel
Private EditTextContactNo As EditText
Private PanelForContactNo As Panel
Private Label6 As Label
Private Label5 As Label
Private Panel1 As Panel
Private ImageView2 As ImageView
Private ImageView1 As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
cartBitmap = LoadBitmap(File.DirAssets, "cart.png")
End If
Activity.LoadLayout("CreateAccount")
' ToolbarHelper.Initialize
' ToolbarHelper.ShowUpIndicator = True 'set to true to show the up arrow
' ToolbarHelper.UpIndicatorDrawable = BitmapToBitmapDrawable(LoadBitmap(File.DirAssets, "hamburger.png"))
' ACToolBarLight1.InitMenuListener
' sm.Initialize("sm")
' Dim offset As Int = 100dip
' sm.BehindOffset = offset
' sm.Mode = sm.LEFT
' Dim lftMenu As Panel
'
' lftMenu.Initialize("")
' sm.Menu.AddView(lftMenu, 0, 0, 100%x - offset, 100%y)
' lftMenu.LoadLayout("Left")
' For i = 1 To 30
' ListView1.AddSingleLine("Item " & i)
' Next
Private cd As ColorDrawable
cd.Initialize(Colors.Transparent,0)
EditTextName.Background = cd
EditTextPassword.Background = cd
EditTextEmail.Background = cd
EditTextContactNo.Background = cd
TextScale = GetDeviceLayoutValues.Height/800
TextScale2 = TextScale / GetDeviceLayoutValues.Scale
Label5.TextSize = 20 * TextScale2
Label6.TextSize = 14 * TextScale2
EditTextName.TextSize = 14 * TextScale2
EditTextEmail.TextSize = 14 * TextScale2
EditTextPassword.TextSize = 14 * TextScale2
EditTextContactNo.TextSize = 14 * TextScale2
Button1.TextSize = 14 * TextScale2
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ACToolBarLight1_NavigationItemClick
sm.ShowMenu
End Sub
Sub Activity_CreateMenu(Menu As ACMenu)
Menu.Clear
Menu.Add(0, 0, "Overflow1", Null)
Menu.Add(0, 0, "Overflow2", Null)
Menu.Add(0, 0, "Overflow3", Null)
Dim item As ACMenuItem = ACToolBarLight1.Menu.Add2(0, 0, "cart", Null)
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge))
End Sub
Sub btnBadge_Click
badge = badge + 1
UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge))
End Sub
Sub btnClearBadge_Click
badge = 0
UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge))
End Sub
Sub AddBadgeToIcon(bmp As Bitmap, Number As Int) As Bitmap
Dim cvs As Canvas
Dim mbmp As Bitmap
mbmp.InitializeMutable(32dip, 32dip)
cvs.Initialize2(mbmp)
Dim target As Rect
target.Initialize(0, 0, mbmp.Width, mbmp.Height)
cvs.DrawBitmap(bmp, Null, target)
If Number > 0 Then
cvs.DrawCircle(mbmp.Width - 8dip, 8dip, 8dip, Colors.Red, True, 0)
cvs.DrawText(Min(Number, 9), mbmp.Width - 8dip, 12dip, Typeface.DEFAULT_BOLD, 12, Colors.White, "CENTER")
End If
Return mbmp
End Sub
Sub UpdateIcon(MenuTitle As String, Icon As Bitmap)
Dim m As ACMenuItem = GetMenuItem(MenuTitle)
m.Icon = BitmapToBitmapDrawable(Icon)
End Sub
Sub BitmapToBitmapDrawable (bitmap As Bitmap) As BitmapDrawable
Dim bd As BitmapDrawable
bd.Initialize(bitmap)
Return bd
End Sub
Sub ACToolBarLight1_MenuItemClick (Item As ACMenuItem)
Log("Clicked: " & Item.Title)
End Sub
Sub GetMenuItem(Title As String) As ACMenuItem
For i = 0 To ACToolBarLight1.Menu.Size - 1
Dim m As ACMenuItem = ACToolBarLight1.Menu.GetItem(i)
If m.Title = Title Then
Return m
End If
Next
Return Null
End Sub
Sub Button1_Click
StartActivity(Login)
End Sub
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
#Extends: android.support.v7.app.AppCompatActivity
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Private badge As Int
Private cartBitmap As Bitmap
Dim txt As String
Dim SQL1 As SQL
Dim dbCursor As Cursor
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 TextScale As Float
Dim TextScale2 As Float
Private Label1 As Label
Private ImageView1 As ImageView
Private Label2 As Label
Private CLV1 As CustomListView
Private Panel1 As Panel
Private ACToolBarLight1 As ACToolBarLight
Private ToolbarHelper As ACActionBar
' Dim cartBadge As Badger
Private Button1 As Button
Private Label5 As Label
Private Label4 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
If FirstTime Then
cartBitmap = LoadBitmap(File.DirAssets, "cart.png")
If File.Exists(File.DirInternal, "grocer.db") = False Then
File.Copy(File.DirAssets, "grocer.db", File.DirInternal, "grocer.db")
End If
SQL1.Initialize(File.DirInternal, "grocer.db", True)
End If
Activity.LoadLayout("PalengkeList")
' TextScale = GetDeviceLayoutValues.Height/800
' TextScale2 = TextScale / GetDeviceLayoutValues.Scale
'
' Label1.TextSize = 16 * TextScale2
' Label2.TextSize = 10 * TextScale2
' Label4.TextSize = 14 * TextScale2
' Label5.TextSize = 14 * TextScale2
ToolbarHelper.Initialize
ToolbarHelper.ShowUpIndicator = True 'set to true to show the up arrow
ToolbarHelper.UpIndicatorDrawable = BitmapToBitmapDrawable(LoadBitmap(File.DirAssets, "hamburger.png"))
ACToolBarLight1.InitMenuListener
ProgressDialogShow2("Please Wait...",False)
ExecuteRemoteQuery("SELECT * FROM `market` order by id" , "Markets")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_CreateMenu(Menu As ACMenu)
Log("Munu Added")
Menu.Clear
Menu.Add(0, 0, "Overflow1", Null)
Menu.Add(0, 0, "Overflow2", Null)
Menu.Add(0, 0, "Overflow3", Null)
Dim item As ACMenuItem = ACToolBarLight1.Menu.Add2(0, 0, "cart", Null)
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge))
End Sub
Sub AddBadgeToIcon(bmp As Bitmap, Number As Int) As Bitmap
Dim cvs As Canvas
Dim mbmp As Bitmap
mbmp.InitializeMutable(32dip, 32dip)
cvs.Initialize2(mbmp)
Dim target As Rect
target.Initialize(0, 0, mbmp.Width, mbmp.Height)
cvs.DrawBitmap(bmp, Null, target)
If Number > 0 Then
cvs.DrawCircle(mbmp.Width - 8dip, 8dip, 8dip, Colors.Red, True, 0)
cvs.DrawText(Min(Number, 9), mbmp.Width - 8dip, 12dip, Typeface.DEFAULT_BOLD, 12, Colors.White, "CENTER")
End If
Return mbmp
End Sub
Sub UpdateIcon(MenuTitle As String, Icon As Bitmap)
Dim m As ACMenuItem = GetMenuItem(MenuTitle)
m.ShowAsAction = m.SHOW_AS_ACTION_ALWAYS
m.Icon = BitmapToBitmapDrawable(Icon)
End Sub
Sub BitmapToBitmapDrawable (bitmap As Bitmap) As BitmapDrawable
Dim bd As BitmapDrawable
bd.Initialize(bitmap)
Return bd
End Sub
Sub ACToolBarLight1_MenuItemClick (Item As ACMenuItem)
Log("Clicked: " & Item.Title)
End Sub
Sub GetMenuItem(Title As String) As ACMenuItem
For i = 0 To ACToolBarLight1.Menu.Size - 1
Dim m As ACMenuItem = ACToolBarLight1.Menu.GetItem(i)
If m.Title = Title Then
Return m
End If
Next
Return Null
End Sub
Private Sub CreateItem(Width As Int, Market As String, Image As String, Address As String) As Panel
Dim p As Panel
p.Initialize("")
Dim Height As Int = 20%Y
' If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then Height = 210dip
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("PalengkeListLayout")
Label1.Text = Market
Label2.Text = Address
' lblContent.Text = Content
' SetColorStateList(Label2, xui.Color_LightGray, Label2.TextColor)
' SetColorStateList(lblAction2, xui.Color_LightGray, lblAction2.TextColor)
Dim bmp As Bitmap
bmp.Initialize(File.DirAssets,Image)
ImageView1.SetBackgroundImage(bmp)
Return p
End Sub
Sub SetColorStateList(Btn As Label,Pressed As Int,Enabled As Int)
Dim States(2,1) As Int
States(0,0) = 16842919 'Pressed
States(1,0) = 16842910 'Enabled
Dim CSL As JavaObject
CSL.InitializeNewInstance("android.content.res.ColorStateList",Array(States,Array As Int(Pressed, Enabled)))
Dim B1 As JavaObject = Btn
B1.RunMethod("setTextColor",Array As Object(CSL))
End Sub
Sub CLV1_ItemClick (Index As Int, Value As Object)
Main.manager.SetString("market",Value)
StartActivity(Shop)
End Sub
Sub ACToolBarLight1_NavigationItemClick
End Sub
Sub JobDone(Job As HttpJob)
If Job.Success Then
Dim res As String
res = Job.GetString
' Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select Job.JobName
Case "Markets"
CLV1.Clear
txt = "DELETE FROM Shops"
SQL1.ExecNonQuery(txt)
Dim l As List
l = parser.NextArray 'returns a list with maps
For i = 0 To l.Size - 1
Dim m As Map
m = l.Get(i)
txt = "INSERT INTO Shops(Name,`Address`,Category,Description,Lat,Long,Status) VALUES ('"& m.Get("storename") &"','" & m.Get("description") &"','" & m.Get("category") &"','" & m.Get("description") &"','" & m.Get("lat") &"','" & m.Get("long") &"','" & m.Get("status") &"')"
Log(txt)
SQL1.ExecNonQuery(txt)
CLV1.Add(CreateItem(CLV1.AsView.Width, m.Get("storename"), m.Get("picture"), m.Get("description")), m.Get("storename"))
Next
ProgressDialogHide
Job.Release
End Select
Else
ProgressDialogHide
ToastMessageShow("Error: " &"No Internet", True)
End If
End Sub
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("http://8box.8boxerp.com/connect/connect_FoodBox.php", Query)
End Sub
It has no errors. Here is the codeMain Activity:#Region Project Attributes #ApplicationLabel: Food Box #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 #Extends: android.support.v7.app.AppCompatActivity #BridgeLogger: true Sub Process_Globals Private badge As Int Private cartBitmap As Bitmap Dim manager As PreferenceManager End Sub Sub Globals Dim TextScale As Float Dim TextScale2 As Float Private ACToolBarLight1 As ACToolBarLight Private ToolbarHelper As ACActionBar Private sm As SlidingMenu Private ListView1 As ListView Private Button1 As Button ' Private EditTextPassword As EditText ' Private PanelForPassword As Panel ' Private Label4 As Label ' Private EditTextUsername As EditText ' Private PanelForUsername As Panel ' Private Label3 As Label ' Private EditTextContactNo As EditText ' Private PanelForContactNo As Panel ' Private Label2 As Label ' Private Label1 As Label ' Private EditTextName As EditText ' Private PanelForName As Panel Private EditTextName As EditText Private PanelForName As Panel Private EditTextEmail As EditText Private PanelForEmail As Panel Private EditTextPassword As EditText Private PanelForPassword As Panel Private EditTextContactNo As EditText Private PanelForContactNo As Panel Private Label6 As Label Private Label5 As Label Private Panel1 As Panel Private ImageView2 As ImageView Private ImageView1 As ImageView End Sub Sub Activity_Create(FirstTime As Boolean) If FirstTime Then cartBitmap = LoadBitmap(File.DirAssets, "cart.png") End If Activity.LoadLayout("CreateAccount") ' ToolbarHelper.Initialize ' ToolbarHelper.ShowUpIndicator = True 'set to true to show the up arrow ' ToolbarHelper.UpIndicatorDrawable = BitmapToBitmapDrawable(LoadBitmap(File.DirAssets, "hamburger.png")) ' ACToolBarLight1.InitMenuListener ' sm.Initialize("sm") ' Dim offset As Int = 100dip ' sm.BehindOffset = offset ' sm.Mode = sm.LEFT ' Dim lftMenu As Panel ' ' lftMenu.Initialize("") ' sm.Menu.AddView(lftMenu, 0, 0, 100%x - offset, 100%y) ' lftMenu.LoadLayout("Left") ' For i = 1 To 30 ' ListView1.AddSingleLine("Item " & i) ' Next Private cd As ColorDrawable cd.Initialize(Colors.Transparent,0) EditTextName.Background = cd EditTextPassword.Background = cd EditTextEmail.Background = cd EditTextContactNo.Background = cd TextScale = GetDeviceLayoutValues.Height/800 TextScale2 = TextScale / GetDeviceLayoutValues.Scale Label5.TextSize = 20 * TextScale2 Label6.TextSize = 14 * TextScale2 EditTextName.TextSize = 14 * TextScale2 EditTextEmail.TextSize = 14 * TextScale2 EditTextPassword.TextSize = 14 * TextScale2 EditTextContactNo.TextSize = 14 * TextScale2 Button1.TextSize = 14 * TextScale2 End Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Sub ACToolBarLight1_NavigationItemClick sm.ShowMenu End Sub Sub Activity_CreateMenu(Menu As ACMenu) Menu.Clear Menu.Add(0, 0, "Overflow1", Null) Menu.Add(0, 0, "Overflow2", Null) Menu.Add(0, 0, "Overflow3", Null) Dim item As ACMenuItem = ACToolBarLight1.Menu.Add2(0, 0, "cart", Null) item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge)) End Sub Sub btnBadge_Click badge = badge + 1 UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge)) End Sub Sub btnClearBadge_Click badge = 0 UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge)) End Sub Sub AddBadgeToIcon(bmp As Bitmap, Number As Int) As Bitmap Dim cvs As Canvas Dim mbmp As Bitmap mbmp.InitializeMutable(32dip, 32dip) cvs.Initialize2(mbmp) Dim target As Rect target.Initialize(0, 0, mbmp.Width, mbmp.Height) cvs.DrawBitmap(bmp, Null, target) If Number > 0 Then cvs.DrawCircle(mbmp.Width - 8dip, 8dip, 8dip, Colors.Red, True, 0) cvs.DrawText(Min(Number, 9), mbmp.Width - 8dip, 12dip, Typeface.DEFAULT_BOLD, 12, Colors.White, "CENTER") End If Return mbmp End Sub Sub UpdateIcon(MenuTitle As String, Icon As Bitmap) Dim m As ACMenuItem = GetMenuItem(MenuTitle) m.Icon = BitmapToBitmapDrawable(Icon) End Sub Sub BitmapToBitmapDrawable (bitmap As Bitmap) As BitmapDrawable Dim bd As BitmapDrawable bd.Initialize(bitmap) Return bd End Sub Sub ACToolBarLight1_MenuItemClick (Item As ACMenuItem) Log("Clicked: " & Item.Title) End Sub Sub GetMenuItem(Title As String) As ACMenuItem For i = 0 To ACToolBarLight1.Menu.Size - 1 Dim m As ACMenuItem = ACToolBarLight1.Menu.GetItem(i) If m.Title = Title Then Return m End If Next Return Null End Sub Sub Button1_Click StartActivity(Login) End Sub
Another Activity:#Region Activity Attributes #FullScreen: False #IncludeTitle: True #End Region #Extends: android.support.v7.app.AppCompatActivity Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Private xui As XUI Private badge As Int Private cartBitmap As Bitmap Dim txt As String Dim SQL1 As SQL Dim dbCursor As Cursor 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 TextScale As Float Dim TextScale2 As Float Private Label1 As Label Private ImageView1 As ImageView Private Label2 As Label Private CLV1 As CustomListView Private Panel1 As Panel Private ACToolBarLight1 As ACToolBarLight Private ToolbarHelper As ACActionBar ' Dim cartBadge As Badger Private Button1 As Button Private Label5 As Label Private Label4 As Label End Sub Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: If FirstTime Then cartBitmap = LoadBitmap(File.DirAssets, "cart.png") If File.Exists(File.DirInternal, "grocer.db") = False Then File.Copy(File.DirAssets, "grocer.db", File.DirInternal, "grocer.db") End If SQL1.Initialize(File.DirInternal, "grocer.db", True) End If Activity.LoadLayout("PalengkeList") ' TextScale = GetDeviceLayoutValues.Height/800 ' TextScale2 = TextScale / GetDeviceLayoutValues.Scale ' ' Label1.TextSize = 16 * TextScale2 ' Label2.TextSize = 10 * TextScale2 ' Label4.TextSize = 14 * TextScale2 ' Label5.TextSize = 14 * TextScale2 ToolbarHelper.Initialize ToolbarHelper.ShowUpIndicator = True 'set to true to show the up arrow ToolbarHelper.UpIndicatorDrawable = BitmapToBitmapDrawable(LoadBitmap(File.DirAssets, "hamburger.png")) ACToolBarLight1.InitMenuListener ProgressDialogShow2("Please Wait...",False) ExecuteRemoteQuery("SELECT * FROM `market` order by id" , "Markets") End Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Sub Activity_CreateMenu(Menu As ACMenu) Log("Munu Added") Menu.Clear Menu.Add(0, 0, "Overflow1", Null) Menu.Add(0, 0, "Overflow2", Null) Menu.Add(0, 0, "Overflow3", Null) Dim item As ACMenuItem = ACToolBarLight1.Menu.Add2(0, 0, "cart", Null) item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge)) End Sub Sub AddBadgeToIcon(bmp As Bitmap, Number As Int) As Bitmap Dim cvs As Canvas Dim mbmp As Bitmap mbmp.InitializeMutable(32dip, 32dip) cvs.Initialize2(mbmp) Dim target As Rect target.Initialize(0, 0, mbmp.Width, mbmp.Height) cvs.DrawBitmap(bmp, Null, target) If Number > 0 Then cvs.DrawCircle(mbmp.Width - 8dip, 8dip, 8dip, Colors.Red, True, 0) cvs.DrawText(Min(Number, 9), mbmp.Width - 8dip, 12dip, Typeface.DEFAULT_BOLD, 12, Colors.White, "CENTER") End If Return mbmp End Sub Sub UpdateIcon(MenuTitle As String, Icon As Bitmap) Dim m As ACMenuItem = GetMenuItem(MenuTitle) m.ShowAsAction = m.SHOW_AS_ACTION_ALWAYS m.Icon = BitmapToBitmapDrawable(Icon) End Sub Sub BitmapToBitmapDrawable (bitmap As Bitmap) As BitmapDrawable Dim bd As BitmapDrawable bd.Initialize(bitmap) Return bd End Sub Sub ACToolBarLight1_MenuItemClick (Item As ACMenuItem) Log("Clicked: " & Item.Title) End Sub Sub GetMenuItem(Title As String) As ACMenuItem For i = 0 To ACToolBarLight1.Menu.Size - 1 Dim m As ACMenuItem = ACToolBarLight1.Menu.GetItem(i) If m.Title = Title Then Return m End If Next Return Null End Sub Private Sub CreateItem(Width As Int, Market As String, Image As String, Address As String) As Panel Dim p As Panel p.Initialize("") Dim Height As Int = 20%Y ' If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then Height = 210dip p.SetLayoutAnimated(0, 0, 0, Width, Height) p.LoadLayout("PalengkeListLayout") Label1.Text = Market Label2.Text = Address ' lblContent.Text = Content ' SetColorStateList(Label2, xui.Color_LightGray, Label2.TextColor) ' SetColorStateList(lblAction2, xui.Color_LightGray, lblAction2.TextColor) Dim bmp As Bitmap bmp.Initialize(File.DirAssets,Image) ImageView1.SetBackgroundImage(bmp) Return p End Sub Sub SetColorStateList(Btn As Label,Pressed As Int,Enabled As Int) Dim States(2,1) As Int States(0,0) = 16842919 'Pressed States(1,0) = 16842910 'Enabled Dim CSL As JavaObject CSL.InitializeNewInstance("android.content.res.ColorStateList",Array(States,Array As Int(Pressed, Enabled))) Dim B1 As JavaObject = Btn B1.RunMethod("setTextColor",Array As Object(CSL)) End Sub Sub CLV1_ItemClick (Index As Int, Value As Object) Main.manager.SetString("market",Value) StartActivity(Shop) End Sub Sub ACToolBarLight1_NavigationItemClick End Sub Sub JobDone(Job As HttpJob) If Job.Success Then Dim res As String res = Job.GetString ' Log("Response from server: " & res) Dim parser As JSONParser parser.Initialize(res) Select Job.JobName Case "Markets" CLV1.Clear txt = "DELETE FROM Shops" SQL1.ExecNonQuery(txt) Dim l As List l = parser.NextArray 'returns a list with maps For i = 0 To l.Size - 1 Dim m As Map m = l.Get(i) txt = "INSERT INTO Shops(Name,`Address`,Category,Description,Lat,Long,Status) VALUES ('"& m.Get("storename") &"','" & m.Get("description") &"','" & m.Get("category") &"','" & m.Get("description") &"','" & m.Get("lat") &"','" & m.Get("long") &"','" & m.Get("status") &"')" Log(txt) SQL1.ExecNonQuery(txt) CLV1.Add(CreateItem(CLV1.AsView.Width, m.Get("storename"), m.Get("picture"), m.Get("description")), m.Get("storename")) Next ProgressDialogHide Job.Release End Select Else ProgressDialogHide ToastMessageShow("Error: " &"No Internet", True) End If End Sub Sub ExecuteRemoteQuery(Query As String, JobName As String) Dim job As HttpJob job.Initialize(JobName, Me) job.PostString("http://8box.8boxerp.com/connect/connect_FoodBox.php", Query) End Sub
In this example i can only add menu in main activity. But when i try to add new activity and copy the code from main activity, no menu appears in the toolbarAppCompat with ToolBar - minimal example
In most cases AppCompat is no longer needed and will only make things more complicated. B4XPages example with dynamic menu: https://www.b4x.com/android/forum/threads/b4x-menu-badges.133301/ The project attached uses the powerful AppCompat library to replace the built-in ActionBar with a...www.b4x.com
Create a small project and upload it. The problem must be in your codeno menu appears in the toolbar
Here is my example. Just download it here 8boxerp.com/backup/AppCompat.zip. The uploading process is too slow that's why i upload it on our filesCreate a small project and upload it. The problem must be in your code
ONLY THIS time!Here is my example. Just download it here
Is it needed to make menu appears in the toolbar?ONLY THIS time!
If you USE "File-Export as zip" the zip NEVER will be such size for such a small project.
You ZIPPED the complete folder incl Objects folder, incl, backup
1st note: You DID NOT add the Inline Java code in Activity2. Why?
Sub Activity_CreateMenu(Menu As ACMenu)
Menu.Clear
Menu.Add(0, 0, "Overflow1", Null)
Menu.Add(0, 0, "Overflow2", Null)
Menu.Add(0, 0, "Overflow3", Null)
Dim item As ACMenuItem = ACToolBarLight1.Menu.Add2(0, 0, "cart", Null)
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge))
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?