Hi,
I am devoloping a project from the this example https://www.b4x.com/android/forum/threads/appcompat-with-toolbar-minimal-example.79896/
In this case, my app nedd a login activity, this is the code of main activity:
In the loginActivity, after login I call StartActivity(main)
The problem it is, when I call StartActivity(acLogin) in a Activiti_resume of Main, the activity show the layout of main at firts for a few secconds(1 o 2) and after load the login layout, it is a blink bad efect.
The other option, it is to call in Main Activity_Create, but in this case, I have some problems:
1-When I go back to main, after login, the layout show in blank.
2-If I tryed to load the layout or refresh, in the Activity_Resume, trows an error in null pointer exception in object AcMenu when try to add items of the menu, I think for this part of code
I belive that I have more than one error, but I don not know what..
Could any giveme some help to solve the problem? or any example? I review a few examples in the Forum...
Thank you!
I am devoloping a project from the this example https://www.b4x.com/android/forum/threads/appcompat-with-toolbar-minimal-example.79896/
In this case, my app nedd a login activity, this is the code of main activity:
B4X:
Sub Activity_Create(FirstTime As Boolean)
If (FirstTime) Then
DBFileDir = File.DirInternal
DBFileName = clParametros.DbNombre
If File.Exists(DBFileDir, DBFileName) = False Then
DB.Initialize(DBFileDir, DBFileName, True)
'creo tablas
End If
DB.Initialize(DBFileDir, DBFileName, False)
'cargo los parametros
clParametros.LoadParametros
If clParametros.SessionId.Length=0 Then
'StartActivity(acLogin)
End If
End If
Log("menu main")
cartBitmap = LoadBitmap(File.DirAssets, "cart.png")
Activity.LoadLayout("1")
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
Dim jo As JavaObject = ACToolBarLight1
Dim xl As XmlLayoutBuilder
jo.RunMethod("setPopupTheme", Array(xl.GetResourceId("style", "ToolbarMenu")))
End Sub
Sub Activity_Resume
Log("menu resume")
If clParametros.SessionId.Length=0 Then
StartActivity(acLogin)
End If
End Sub
In the loginActivity, after login I call StartActivity(main)
The problem it is, when I call StartActivity(acLogin) in a Activiti_resume of Main, the activity show the layout of main at firts for a few secconds(1 o 2) and after load the login layout, it is a blink bad efect.
The other option, it is to call in Main Activity_Create, but in this case, I have some problems:
1-When I go back to main, after login, the layout show in blank.
2-If I tryed to load the layout or refresh, in the Activity_Resume, trows an error in null pointer exception in object AcMenu when try to add items of the menu, I think for this part of code
B4X:
#If Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
if (processBA.subExists("activity_createmenu")) {
processBA.raiseEvent2(null, true, "activity_createmenu", false, new de.amberhome.objects.appcompat.ACMenuWrapper(menu));
return true;
}
else
return false;
}
#End If
I belive that I have more than one error, but I don not know what..
Could any giveme some help to solve the problem? or any example? I review a few examples in the Forum...
Thank you!