2017-03-20 6 views
0

エミュレータでアプリケーションをテストしていましたが、3ドットボタンが完全に表示されました。3ドットボタンがエミュレータに表示されますが、devieには表示されません

私の実際のデバイス(Samsung Galaxy S3)でテストしたところ、これらの3つのドットボタンは決して出現しませんでした。理由はわかりません。代わりに、私はすべての3つのボタンを得ている、と私は唯一の1つの+ 3つのドットボタン...

を望んでいたことはここに私のメニューです

ここだのOnCreateとのSelectedItem方法

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.menu_affichage_notes,menu); 
    return true; 
} 

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    switch (item.getItemId()) 
    { 
     case R.id.action_logout: 
      //création d'un Intent 
      Intent intent = new Intent(AffichageNotes.this, PageAccueil.class); 
      //ajout de fonctionnalités qui vont être transférés 
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | 
        Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 
      //transfert aussi de la valeur EXIT qui est true 
      intent.putExtra("EXIT", true); 
      startActivity(intent); 
      return true; 
     case R.id.action_setting: 
      Intent a = new Intent(AffichageNotes.this,Reglages.class); 
      startActivity(a); 
      return true; 
     case R.id.action_add: 
      Intent i = new Intent(AffichageNotes.this,AjoutTexte.class); 
      Bundle args = new Bundle(); 
      int id = getIntent().getIntExtra("id",0); 
      i.putExtra("id",id); 
      startActivity(i); 
      return true; 
    } 

    return super.onOptionsItemSelected(item); 
} 

どこからエラーが発生していますか?君たちありがとう !

答えて

0

メニューにアイテムを入れましたか?

<?xml version="1.0" encoding="utf-8"?> 
<menu xmlns:android="http://schemas.android.com/apk/res/android"> 

    <item 
    android:id="@+id/action_add" 
    android:icon="@drawable/ic_action_add" 
    android:title="Ajouter Cours" 
    app:showAsAction="always" /> 

    <item 
     android:id="@+id/action_setting" 
     android:title="Réglages" 
     android:icon="@drawable/ic_action_setting" 
     app:showAsAction="never" 
     /> 
    <item 

     android:id="@+id/action_logout" 
     android:title="Se déconnecter" 
     android:icon="@drawable/ic_action_logout" 
     app:showAsAction="never" 
     /> 

</menu> 

編集:

try { 
     ViewConfiguration config = ViewConfiguration.get(this); 
     FieldmenuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuK‌​ey"); 
     if (menuKeyField != null) { 

     menuKeyField.setAccessible(true); 
     menuKeyField.setBoolean(config, false); 
     } 
    } catch (Exception ex) { 
     return; 
    } 
+0

ソリューションが見えるようにああ、はい、私はcuttedと申し訳ありません、それに気付かなかった... – David

+0

@デビッドは、あなたはアクションバーを見ることができますか?おそらくあなたのテーマのために見ることができない、あなたのstyle.xmlファイルを投稿してもらえますか? –

+1

解決策を見つけました! '試し{ ViewConfiguration config = ViewConfiguration.get(this); フィールドmenuKeyField = ViewConfiguration.class.getDeclaredField( "sHasPermanentMenuKey"); if(menuKeyField!= null){ menuKeyField.setAccessible(true); menuKeyField.setBoolean(config、false); } } catch(例外ex){ //無視する } ' – David

関連する問題