private void CreateActionBar() { ActionBar actionBar = SupportActionBar; Toolbar.LayoutParams layoutParams = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WrapContent, ((actionBar.Height) / 2) - 5); actionBar.SetDisplayShowTitleEnabled(false); actionBar.SetDisplayShowCustomEnabled(true); actionBar.SetCustomView(SetCurrentProjectTitle(), layoutParams); actionBar.SetHomeAsUpIndicator(Resources.GetDrawable(Resource.Drawable.menu_navbar_ham_new)); actionBar.SetDisplayHomeAsUpEnabled(true); actionBar.SetHomeButtonEnabled(true); }
private void HandleMenuSearch() { Android.Support.V7.App.ActionBar action = SupportActionBar; //get the actionbar var imm = (InputMethodManager)GetSystemService(Context.InputMethodService); //edtSeach = (EditText)action.CustomView.FindViewById(Resource.Id.edtSearch); if (isSearchOpened) { //test if the search is open DisableSearch(); } else { //open the search entry action.SetDisplayShowCustomEnabled(true); //enable it to display a // custom view in the action bar. action.SetCustomView(Resource.Layout.SearchBar); //add the custom view action.SetDisplayShowTitleEnabled(false); //hide the title edtSeach = (EditText)action.CustomView.FindViewById(Resource.Id.edtSearch); //the text editor //this is a listener to do a search when the user clicks on search button edtSeach.SetOnEditorActionListener(this); edtSeach.RequestFocus(); //open the keyboard focused in the edtSearch //InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); imm.ShowSoftInput(edtSeach, ShowFlags.Implicit); _Token = edtSeach.WindowToken; //add the close icon _SearchAction.SetIcon(ContextCompat.GetDrawable(this, Resource.Drawable.Forward48)); isSearchOpened = true; } }
protected void InitializeActionBar(Android.Support.V7.App.ActionBar ab) { mActionBar = ab; LayoutInflater mInflater = LayoutInflater.From(this); View mCustomView = mInflater.Inflate(Resource.Layout.ActionBar, null); ActionBarTitle = mCustomView.FindViewById <TextView> (Resource.Id.title); ActionBarBack = mCustomView.FindViewById <ImageButton> (Resource.Id.backButton); ActionBarAdd = mCustomView.FindViewById <ImageButton> (Resource.Id.addButton); ActionBarSearch = mCustomView.FindViewById <ImageButton> (Resource.Id.searchButton); ActionBarClose = mCustomView.FindViewById <ImageButton> (Resource.Id.closeButton); ActionBarDelete = mCustomView.FindViewById <ImageButton> (Resource.Id.deleteButton); ActionBarQuery = mCustomView.FindViewById <EditText>(Resource.Id.query); ActionBarBack.Click += (sender, e) => OnBackPressed(); var layout = new Android.Support.V7.App.ActionBar.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); mActionBar.SetCustomView(mCustomView, layout); mActionBar.SetDisplayShowCustomEnabled(true); }
protected void InitializeActionBar(Android.Support.V7.App.ActionBar ab) { mActionBar = ab; LayoutInflater mInflater = LayoutInflater.From (this); View mCustomView = mInflater.Inflate (Resource.Layout.ActionBar, null); ActionBarTitle = mCustomView.FindViewById<TextView> (Resource.Id.title); ActionBarBack = mCustomView.FindViewById<ImageButton> (Resource.Id.backButton); ActionBarAdd = mCustomView.FindViewById<ImageButton> (Resource.Id.addButton); ActionBarSearch = mCustomView.FindViewById<ImageButton> (Resource.Id.searchButton); ActionBarClose = mCustomView.FindViewById<ImageButton> (Resource.Id.closeButton); ActionBarDelete = mCustomView.FindViewById<ImageButton> (Resource.Id.deleteButton); ActionBarQuery = mCustomView.FindViewById<EditText>(Resource.Id.query); ActionBarBack.Click += (sender, e) => OnBackPressed (); var layout = new Android.Support.V7.App.ActionBar.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); mActionBar.SetCustomView (mCustomView, layout); mActionBar.SetDisplayShowCustomEnabled (true); }