2017-03-20 4 views
0

Ich habe meine App mit einem Emulator getestet und meine 3-Punkt-Taste wurde perfekt angezeigt.3-Punkt-Taste erscheint im Emulator, aber nicht im Gerät

Als ich mit meinem echten Gerät (Samsung Galaxy S3) getestet habe, erschien dieser 3-Punkt-Knopf nie, und ich weiß nicht warum. Stattdessen bin ich alle 3 Tasten bekommen, und ich wollte nur 1 + 3 der Punkt Tasten ...

Hier ist mein Menü

Hier ist die OnCreate und SelectedItem Methoden

@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); 
} 

Woher kommt der Fehler? Danke Jungs !

Antwort

0

Haben Sie Ihre Artikel in ein Menü eingefügt?

<?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> 

Edit: machen Lösung sichtbar

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

oh ja ja, ich zerschnitt und habe es nicht traurig feststellen .. – David

+0

@ David Können Sie die Aktionsleiste sehen? Vielleicht können Sie wegen Ihres Themas nicht sehen, können Sie bitte Ihre style.xml Datei posten? –

+1

Die Lösung gefunden! 'versuchen { ViewConfiguration config = ViewConfiguration.get (this); Feld menuKeyField = ViewConfiguration.class.getDeclaredField ("sHasPermanentMenuKey"); if (menuKeyField! = Null) { menuKeyField.setAccessible (true); menuKeyField.setBoolean (config, false); } } catch (Ausnahme ex) { // Ignoriere } ' – David

Verwandte Themen