Android Tutorial Material Design 3 - Using a ToolBar as ActionBar

Ian Garton

Member
Licensed User
Longtime User

I'm having similar issues. Activity.AddMenu is no good as there doesn't appear to be any method to remove or hide menu items.
ActionBar.Menu looks like it has the required methods, but I'm unable to make a menu appear on the ACToolBar.
 

KL7000F

Member
Licensed User
Longtime User
Hello,

if I use this example it works just fine! But when I use Notification and there use colored icons, then they will not appear on Android 5 in color.

Screenshots:



How do I solve this "problem"?

greeting
Andy
 
Last edited:

RandomCoder

Well-Known Member
Licensed User
Longtime User
This is the new Material way of showing the notification icon, see here for guidance...
http://developer.android.com/design/style/iconography.html#notification

Reading this from Google doc's it appears as though any icon you choose will be used as a mask to create the white notification icon...
Maybe there is a way to change this behaviour but then you would be going against the Material guidelines
 

woniol

Active Member
Licensed User
Longtime User
Hi,
I would like to change ActionBar color between Activities.
Is it possible to change it's color in code?
I would appreciate some examples if it's possible.

Maciej
 

corwin42

Expert
Licensed User
Longtime User
Hi,
I would like to change ActionBar color between Activities.
Is it possible to change it's color in code?
I would appreciate some examples if it's possible.
Since this tutorial is about the ToolBar you can use just the Color attribute of the ACToolBarLight or ACToolBarDark Toolbars.
 

fgrdovic21

Member
Licensed User
Longtime User
Hello to ya all

Unfortunately, I'm unable to make my app work. It won't even start.
On load, it instantly crashes with no errors in log. It displays message: "Unfortunately, app has stopped".
Here's my code:

B4X:
    #Region  Project Attributes
    #ApplicationLabel: app
    #VersionCode: 1
    #VersionName: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

#AdditionalRes: ..\resource
#AdditionalRes: D:\Programs\Basic4android\Libraries\b4a_appcompat, de.amberhome.objects.appcompat
#AdditionalRes: D:\Programs\Android\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#Extends: android.support.v7.app.ActionBarActivity

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

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.

    Private ActionBar As ACToolBarLight
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Main")
    ActionBar.SetAsActionBar

    'Set Title and Subtitle for the ToolBar
    ActionBar.Title = "AppCompat"
    ActionBar.SubTitle = "ToolBar Example 1"
  
    Dim AC As AppCompat
    AC.SetElevation(ActionBar, 8dip)
  
    'Dim ABHelper As ACActionBar
    'ABHelper.Initialize
    'ABHelper.ShowUpIndicator = True
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Layout "Main" is set the same way the tutorial shows.
This is theme.xml

B4X:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Teal" parent="Theme.AppCompat.Light">
        <item name="colorPrimary">#009688</item>
        <item name="colorPrimaryDark">#00897B</item>
        <item name="colorAccent">#009688</item>
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
    </style>
</resources>

I've been searching for this error last two days and was unable to find solution. This happens on LG Optimus G running Android 5.1.1 CyanogenMod 12.1 and Samsung Galaxy Tab 3 running stock Android 4.4.2. Any help is really appreciated. Thanks!
 

fgrdovic21

Member
Licensed User
Longtime User
Where are the logs?

The thing is that they don't show anything:

B4X:
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:com.serbapp.app
** Activity (main) Resume **

This is without filter checked:

B4X:
LogCat connected to: B4A-Bridge: LGE LG-E975
--------- beginning of main
** Activity (main) Resume **
Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
Timeline: Activity_idle id: android.os.BinderProxy@3d3d382f time:17964435
** Service (service1) Destroy **
Ignoring event as service was destroyed: server_newconnection
** Service (service1) Create **
** Service (service1) Start **
Connected to B4A-Bridge (Wifi)
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:com.serbapp.tunora
** Activity (main) Resume **
Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
Timeline: Activity_idle id: android.os.BinderProxy@3d3d382f time:18024125
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
Timeline: Activity_idle id: android.os.BinderProxy@3d3d382f time:18038336
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:com.serbapp.tunora
** Activity (main) Resume **
Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
Timeline: Activity_idle id: android.os.BinderProxy@3d3d382f time:18154647
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
Timeline: Activity_idle id: android.os.BinderProxy@3d3d382f time:18167263
 

corwin42

Expert
Licensed User
Longtime User

Try to connect your devices via USB. This should show the error in the unfiltered logs.

Please post your Manifest.
 

fgrdovic21

Member
Licensed User
Longtime User
Try to connect your devices via USB. This should show the error in the unfiltered logs.

Please post your Manifest.

Manifest:
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="5" android:targetSdkVersion="22"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
SetApplicationAttribute(android:theme, "@style/Teal")
'End of default text.

The thing is, I'm using Windows 10 and ADB Driver is not compatible with it. I don't know if its a B4A bug or Windows , but B4A cannot find my device, thus I'm forced to use B4A Bridge.
 

thedesolatesoul

Expert
Licensed User
Longtime User
The thing is, I'm using Windows 10 and ADB Driver is not compatible with it. I don't know if its a B4A bug or Windows , but B4A cannot find my device, thus I'm forced to use B4A Bridge.
Probably a windows bug. Also, you could try running it on genymotion to get the logs.
 

kmap

Member
Licensed User
Longtime User
i get this error java.lang.RuntimeException: Unable to start activity ComponentInfo{my.book/my.book.main}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content

Regrads
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…