Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25669

Android: when using Ti.UI.Toolbar as ActionBar, onHomeIconItemSelected doesn't work

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Not Our Bug
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Android
    • Environment:

      MacOS Sierra 10.12.4
      Appcelerator Studio 5.0.0
      Titanium SDK 7.0.1.GA
      Google Nexus 5X 7.1.0 (emulator)

    • Story Points:
      0
    • Sprint:
      2018 Sprint 01 SDK

      Description

      I'm using a Toolbar as an ActionBar and I want to show the left drawer menu when clicking on the navigation icon, but the problem is that nothing happens when I click it.

      Check my code below.

      view/xml:

      <Alloy>
      	<Window class="container" id="window" onOpen="open" title="Directions List" >
      		
      		<DrawerLayout id="drawerLayout">
      			
      			<LeftView>
      				
      			</LeftView>
      			
      			<CenterView>
      				<View>
      					<Toolbar
      						title="Directions List"
      						width="Ti.UI.FILL"
      						elevation="10"
      						top="0"
      						barColor="#db4337"
      						titleTextColor="white"
      						displayHomeAsUp="true"
      						homeButtonEnabled="true" 
      						id="actionBar"
      						navigationIcon="/icons/nav_menu_white.png" / > 
      					  
      					<Label text="test" />
      					
      				</View>
       
      			</CenterView>
      		</DrawerLayout>
       
      	</Window>
      </Alloy>
      

      style/tss:

      "Window":{
      	theme : 'AppTheme.TransBtns.Drawer',
      	windowSoftInputMode: Ti.UI.Android.SOFT_INPUT_STATE_HIDDEN
      }
      

      android theme:

      <style name="AppTheme.TransBtns.Drawer" parent="Theme.AppCompat.Light.DarkActionBar">
          	<item name="windowActionBar">false</item>
              <item name="windowNoTitle">true</item>
      	<item name="android:buttonStyle">
      		@style/Widget.AppCompat.Button.Borderless.Colored
      	</item>
      </style>
      

      controller/js:

      function open() {
      	var activity = $.window.getActivity();
      	
      	if (activity) {
      		var actionBar = activity.getActionBar();
      		if (actionBar) {
      			actionBar.displayHomeAsUp = true;
      			actionBar.onHomeIconItemSelected = function() {
      				$.drawerLayout.toggleLeft();
      			};
      		}
      	}
      }
      

      I tried showing on console the value of activity.getActionBar() and apparently it shows the value of the original ActionBar, the one which isn't visible, instead of showing the Toolbar.

      I also tried this but nothing happens:

      // $.actionBar is the id of the Toolbar
      $.actionBar.onHomeIconItemSelected = function() {
      	$.drawerLayout.toggleLeft();
      };
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gfigueras Guillermo Figueras
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-6091
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code