Android Question Interact with ActionBar

hugorinen

Member
Licensed User
Longtime User
Hi all,

I made a simple app in Java and it used these two methods :

public abstract void setDisplayShowTitleEnabled (boolean showTitle)
public abstract void setDisplayShowHomeEnabled (boolean showHome)

To hide the ActionBar when I used the Tabs mode.

I tried :

B4X:
Dim ActionBar,Activity_ As JavaObject
    Activity_.InitializeStatic("android.app.Activity")
    ActionBar.InitializeStatic("android.app.ActionBar")
    ActionBar = Activity_.RunMethod("getActionBar",Null) 'Fail here
    ActionBar.RunMethod("setDisplayShowHomeEnabled", Array As Object(False))
    ActionBar.RunMethod("setDisplayShowTitleEnabled",Array As Object(False))

But it fails :

B4X:
java.lang.IllegalArgumentException: expected receiver of type android.app.Activity, but got java.lang.Class<android.app.Activity>
In Java the code is :

B4X:
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setDisplayShowHomeEnabled(false);

Thanks in advance !
 
Last edited:

hugorinen

Member
Licensed User
Longtime User
Thanks it works now !

Here's my final code :

B4X:
    Dim ActionBar as StdActionBar
    ActionBar.Initialize("ActionBar")
    ActionBar.NavigationMode = ActionBar.NAVIGATION_MODE_TABS
   
    Dim stdbar As JavaObject
    stdbar = ActionBar
    stdbar = stdbar.GetField("bar")
    stdbar.RunMethod("setDisplayShowHomeEnabled", Array As Object(False))
    stdbar.RunMethod("setDisplayShowTitleEnabled",Array As Object(False))
 
Upvote 0
Top