Android Question StdActionBar

Discussion in 'Android Questions' started by Derek Jee, Jul 18, 2015.

  1. Derek Jee

    Derek Jee Active Member Licensed User

    Hi there

    Anyone know if I can disable a button in my stdActionBar? I have an ok/cancel panel showing to the user and do not want them to be able to click the buttons in the Action Bar.. Or if I can make my panel full screen which covers the Action Bar, that would work also..

    Thank you :))

    Derek.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You cannot cover the ActionBar. You can use a global flag variable to decide whether you need to ignore the event or handle it.
     
    Derek Jee likes this.
  3. Derek Jee

    Derek Jee Active Member Licensed User

    Does this also mean that I cannot change any icons at runtime?

    Thank you again..
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You can change the action bar icon with StdActionBar.Icon.
     
  5. Derek Jee

    Derek Jee Active Member Licensed User

    Can I change the menuitem icons at runtime? If not is there a lib which will let me change a menu icon at runtime so I can indicate to the user of a change in a status?

    Thank you
     
    Last edited: Aug 8, 2015
  6. Erel

    Erel Administrator Staff Member Licensed User

    No. That is not possible. You can however add a custom view to the bar and then you will have full control over it.
     
  7. Derek Jee

    Derek Jee Active Member Licensed User

    Thank you for confirming Erel.. Any chance there is some code showing this or similar somewhere?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

  9. Derek Jee

    Derek Jee Active Member Licensed User

    Thank you Erel

    I have added this code into my app and have now got an icon in my action bar.. The icon shows on the left after the action bar title but all of my other icons are on the right. How can I move the icon across to the right and do you suggest to use this method for all of my icons instead of the addmenuitem etc?

    Thank you!


    Derek

    Code:
    edtTeste.Initialize("")
    edtTeste.SetBackgroundImage(
    LoadBitmap(File.DirAssets,"ic_restore_white_24dp.png"))
    Dim jo As JavaObject = ActionBar
    jo = jo.GetField(
    "bar")
    jo.RunMethod(
    "setDisplayShowCustomEnabled"Array As Object(True))
    jo.RunMethod(
    "setCustomView"Array As Object(edtTeste))
    edtTeste.Width = 
    4%y
    End Sub
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    Try to add a panel and then add the icons to the panel. Yes, you should add such buttons instead of the standard menu items if you want to replace them at runtime.
     
    Derek Jee likes this.
  11. Derek Jee

    Derek Jee Active Member Licensed User

    Super!!!! It worked a treat, thank you..
     
Loading...