Android Question material design action bar home button

jayel

Active Member
Licensed User
Longtime User
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
#Extends: android.support.v7.app.AppCompatActivity
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.
    Dim AC As AppCompat
    Dim ABHelper As ACActionBar
    Private ActionBar As ACToolBarLight
    Private lblContent As Label
    Private lblDatum As Label
    Private lblDetail As Label
    Private lblTitle As Label
    Private pContent As Panel
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("detailberichtlayout")
    'ActionBar.InitMenuListener
    ActionBar.SetAsActionBar
    ABHelper.Initialize
    pContent.LoadLayout("detailberichtcontentlayout")
    Dim myicon As String = ""
    Select Case Starter.selected_notificationsoort.soort
        Case "P"
            myicon = "gateicon128.png"
        Case "A"
            myicon = "bellicon.png"
        Case "K"
            myicon = "bearicon.png"
        Case "D"
            myicon = "homeicon.png"
    End Select
    'privbar.Icon = LoadBitmap(File.DirAssets,myicon)
   
    ActionBar.LogoBitmap = LoadBitmap(File.DirAssets, myicon)
    Dim readabledatum As String
    DateTime.DateFormat= "dd/MM/yyyy"
    DateTime.TimeFormat = "HH:mm:ss"
   
    readabledatum = DateTime.Date(Starter.selected_customnotification.datum) & " " &  DateTime.Time(Starter.selected_customnotification.datum)
   
    lblDatum.Text = readabledatum
    lblTitle.Text = Starter.selected_customnotification.title
    lblContent.Text = Starter.selected_customnotification.content
    lblDetail.Text = Starter.selected_customnotification.detail
    ABHelper.ShowUpIndicator = True
End Sub

Sub Activity_ActionBarHomeClick
    Log ("klik")
    Activity.Finish
   
   
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

the "Activity_ActionBarHomeClick" will not fire.
Does anybody have a clue?

Greets John
 

jayel

Active Member
Licensed User
Longtime User
Hey Erel,

That doens't seem to solve the problem.
The event doens't fire at all.
The previous activity (the activity that calls the activity above), there it works....

Strange !
 
Upvote 0

jayel

Active Member
Licensed User
Longtime User
yes here is a test project, the click event does not fire !
 

Attachments

  • testmaterial.zip
    8.3 KB · Views: 210
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
See the comment in corwin42 example:
B4X:
'If you don't have a Menu in your app and want to handle the "back" arrow in the Toolbar,
'yout have to call ToolBarXXX.InitMenuListener and use this event.
Sub ActionBar_NavigationItemClick
   Log("Will be enabled if you call ToolBarXXX.InitMenuListener")
End Sub

This code works:
B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim AC As AppCompat
   Dim ABHelper As ACActionBar

   Private ActionBar As ACToolBarLight
   
   Private pContent As Panel
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("mainlayout")
   ActionBar.SetAsActionBar
   ActionBar.InitMenuListener
   ActionBar.Title = "Title"
   ActionBar.SubTitle = "Subtitle"
   ABHelper.Initialize
   ABHelper.ShowUpIndicator = True
End Sub

'If you don't have a Menu in your app and want to handle the "back" arrow in the Toolbar,
'yout have to call ToolBarXXX.InitMenuListener and use this event.
Sub ActionBar_NavigationItemClick
   Log("Will be enabled if you call ToolBarXXX.InitMenuListener")
End Sub
 
Upvote 0
Top