2016-12-13 17 views
0

私のXamarin Androidアプリ(3ドット)のハードウェアメニューボタンのオーバーフローアイコンを非表示にする必要があります - スクリーンショットを参照してください。Xamarin Androidのハードウェアメニューボタンでオーバーフローアイコンを非表示にする方法

どうすればよいですか?

enter image description here

+0

の右隅にいくつかは、あなたの活動からメソッドをOnCreateOptionsMenu削除します。私はあなたがActionBarを使用していると仮定します。オーバーバーメニューをActionBarに表示する必要がある場合は、ActionBarではなくToolbarを使用してください。 – HeisenBerg

+0

私はOnCreateOptionsMenuメソッドを持っていません –

+0

どのようにオーバーフローアイコンを取得しますか?任意のコードまたはXML? –

答えて

1

私はネクサス6にオーバーフローアイコンを見つけられませんでしたが、私はあなたにいくつかの提案を与えるたいと思います:

Android.App.Activityは、JavaアンドロイドのActivity間で異なるxamarinアンドロイドプロジェクトのために。

// Summary: 
//  Initialize the contents of the Activity's standard options menu. 
// 
// Parameters: 
// menu: 
//  The options menu in which you place your items. 
// 
// Returns: 
//  To be added. 
// 
// Remarks: 
//  /// 
//  Initialize the contents of the Activity's standard options menu. You /// should 
//  place your menu items in to menu. /// /// 
//  /// 
//  This is only called once, the first time the options menu is /// displayed. To 
//  update the menu every time it is displayed, see /// Android.App.Activity.OnPrepareOptionsMenu(Android.Views.IMenu). 
//  /// /// 
//  /// 
//  The default implementation populates the menu with standard system /// menu items. 
//  These are placed in the Android.Views.Menu.CATEGORY_SYSTEM group so that /// 
//  they will be correctly ordered with application-defined menu items. /// Deriving 
//  classes should always call through to the base implementation. /// /// 
//  /// 
//  You can safely hold on to menu (and any items created /// from it), making modifications 
//  to it as desired, until the next /// time onCreateOptionsMenu() is called. /// 
//  /// 
//  /// 
//  When you add items to the menu, you can implement the Activity's /// Android.App.Activity.OnOptionsItemSelected(Android.Views.IMenuItem) 
//  method to handle them there. 
//  /// 
//  /// /// [Android Documentation] /// /// 
//  /// 
[Register("onCreateOptionsMenu", "(Landroid/view/Menu;)Z", "GetOnCreateOptionsMenu_Landroid_view_Menu_Handler")] 
public virtual bool OnCreateOptionsMenu(IMenu menu); 

このonCreateOptionsMenu機能がデフォルトとして呼び出されます:活動は、それは次の関数を呼び出しますメニューを作成するとき

は、我々はAndroid.App.Activityのソースコードを見つけることができます。 Xamarin androidは、Java AndroidのonCreateOptionsMenu機能をカプセル化しています。私は次のようにMainActivityの関数をオーバーライドできると思います:

public class MainActivity : Activity 
    { 
     protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 

      // Set our view from the "main" layout resource 
      SetContentView (Resource.Layout.Main); 
     } 

     public override bool OnCreateOptionsMenu(Android.Views.IMenu menu) 
     { 
      return false; 
     } 
    } 

メニューはデフォルトで作成する必要があります。

0

それらのいくつかは、お使いのデバイスのようなオプションメニューを作成し、特定のデバイスとそのOSに依存しますが、トップ

関連する問題