/** * Sets up the compatibility action bar with the given title. */ private void setupActionBar() { ViewGroup actionBarCompat = getActionBarCompat(); if (actionBarCompat == null) { return; } LinearLayout.LayoutParams springLayoutParams = new LinearLayout.LayoutParams( 0, ViewGroup.LayoutParams.FillParent); springLayoutParams.Weight = 1; // Add Home button SimpleMenu tempMenu = new SimpleMenu(mActivity); SimpleMenuItem homeItem = new SimpleMenuItem( tempMenu, Resource.Id.home, 0, mActivity.GetString(Resource.String.app_name)); homeItem.setIcon(Resource.Drawable.Icon); addActionItemCompatFromMenuItem(homeItem); // Add title text TextView titleText = new TextView(mActivity, null, Resource.attr.actionbarCompatTitleStyle); titleText.LayoutParameters = springLayoutParams; titleText.SetText(mActivity.Title); actionBarCompat.AddView(titleText); }
/** * Adds an item to the menu. The other add methods funnel to this. */ private IMenuItem addInternal(int itemId, int order, CharSequence title) { SimpleMenuItem item = new SimpleMenuItem(this, itemId, order, title); mItems.Add(findInsertIndex(mItems, order), item); return item; }