Android Question AddMenuItem3 icon not appear

angel

Member
Licensed User
Longtime User
Once it appears and others do not, attached codig manifes

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

''CreateResource(values-v20, theme.xml,
''<resources>
''    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
''         <item name="android:colorPrimary">@color/actionbar</item>
''         <item name="android:textColor">@color/textColor</item>
''         <item name="android:textColorPrimary">@color/textColorPrimary</item>
''    </style>
''</resources>

AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="25"/>
<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.

' Personalitzar ActionBar
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values, colors.xml,
<resources>
    <color name="actionbar">#ff3F51B5</color>
    <color name="textColor">#ff000000</color>
    <color name="textColorPrimary">#ff000000</color>
</resources>
)
CreateResource(values-v20, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
         <item name="android:colorPrimary">@color/actionbar</item>
         <item name="android:textColor">@color/textColor</item>
         <item name="android:textColorPrimary">@color/textColorPrimary</item>
    </style>
</resources>
)
CreateResource(values-v14, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
    </style>
    <style name="CustomActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@color/actionbar</item>
    </style>
</resources>
)

Code AddMenuItems

B4X:
Private Sub CrearMenusActivity
    Activity.AddMenuItem3(Codi.Lang("Main.MenuItem2","Sincronizar"),"BSincro", LoadBitmap(File.DirAssets, "ic_sincronize.png"), True)
    Activity.AddMenuItem3(Codi.Lang("Main.MenuItem1","Crear operación"),"BCrear", LoadBitmap(File.DirAssets, "ic_add.png"), True)
    Activity.AddMenuItem3(Codi.Lang("Main.MenuItem10","Crear mensajes"),"BMensaje", LoadBitmap(File.DirAssets, "ic_new_message.png"), True)
    Activity.AddMenuItem3(Codi.Lang("Main.MenuItem3","Filtrar"),"BFiltrar", LoadBitmap(File.DirAssets, "ic_search.png"), True)
    Activity.AddMenuItem3(Codi.Lang("Main.MenuItem4","Ordenar"),"BOrdre", LoadBitmap(File.DirAssets, "ic_order.png"), True)
    Activity.AddMenuItem(Codi.Lang("Main.MenuItem5","Configuración"),"BConfig")
    Activity.AddMenuItem(Codi.Lang("Main.MenuItem7","Modo Sincro"),"BModoSincro")
    Activity.AddMenuItem(Codi.Lang("Main.MenuItem8","Cambio de usuario"),"BCambio")
    Activity.AddMenuItem(Codi.Lang("Main.MenuItem6","Cerrar sesión"),"BLogout")
    Activity.AddMenuItem(Codi.Lang("AcercaDe", "Acerca de ..."), "BAbout")
End Sub
 

Attachments

  • Screenshot_20180326-125508.jpg
    Screenshot_20180326-125508.jpg
    194.7 KB · Views: 493
  • Screenshot_2018-03-26-16-18-34.png
    Screenshot_2018-03-26-16-18-34.png
    28.7 KB · Views: 491
Last edited:

angel

Member
Licensed User
Longtime User
have many icons because if it is a mobile I see 2 icons and if it is a tablet I see 4 icons, they are sometimes visible and others are not visible, I have seen that they usually disappear when I pause the application and it also fails when I reinstall the application
 
Upvote 0

angel

Member
Licensed User
Longtime User
Hello

Solved, the problem was that when you closed the application or entered the background had "Activity.Finish", it has been changed to "ExitApplication" and it works fine.

Thank you all
 
Upvote 0

angel

Member
Licensed User
Longtime User
'Change the background to Activity.Finish and close ExitAplication.It's correct ? where is the correct solution ?

Thanks
 
Upvote 0

angel

Member
Licensed User
Longtime User
Hello Erel

The code...
B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        StartActivity(Login)
        CrearMenusActivity
    End If   
End Sub


Private Sub CrearMenusActivity
    Activity.AddMenuItem3(Codi.Lang("Main.MenuItem2","Sincronizar"),"BSincro", LoadBitmap(File.DirAssets, "ic_sincronize.png"), True)
    Activity.AddMenuItem3(Codi.Lang("Main.MenuItem1","Crear operación"),"BCrear", LoadBitmap(File.DirAssets, "ic_add.png"), True)
    Activity.AddMenuItem3(Codi.Lang("Main.MenuItem10","Crear mensajes"),"BMensaje", LoadBitmap(File.DirAssets, "ic_new_message.png"), True)
    Activity.AddMenuItem3(Codi.Lang("Main.MenuItem3","Filtrar"),"BFiltrar", LoadBitmap(File.DirAssets, "ic_search.png"), True)
    Activity.AddMenuItem3(Codi.Lang("Main.MenuItem4","Ordenar"),"BOrdre", LoadBitmap(File.DirAssets, "ic_order.png"), True)
    Activity.AddMenuItem(Codi.Lang("Main.MenuItem5","Configuración"),"BConfig")
    Activity.AddMenuItem(Codi.Lang("Main.MenuItem7","Modo Sincro"),"BModoSincro")
    Activity.AddMenuItem(Codi.Lang("Main.MenuItem8","Cambio de usuario"),"BCambio")
    Activity.AddMenuItem(Codi.Lang("Main.MenuItem6","Cerrar sesión"),"BLogout")
    Activity.AddMenuItem(Codi.Lang("AcercaDe", "Acerca de ..."), "BAbout")
End Sub


Sub BLogout_Click
    CallSubDelayed(Me, "BLogout")
End Sub


Sub BLogout
    Dim opcio As Int

    opcio= Msgbox2(Codi.Lang("Logout.logout","¿Desea cerrar la sesión?"),Codi.Lang("Main.MsgBoxTitleAviso", "Aviso"),Codi.Lang("Si", "Si"),Codi.Lang("No", "No"),"", Null)
    If opcio=DialogResponse.POSITIVE Then
        'Activity.Finish
        ExitApplication
    Else
        
        End If
    End If
    
End Sub

When the user close the app if code is Activit.Finish when restart the icons not apper, change for ExitApplication and work
 
Upvote 0
Top