0
Warum nicht Menü anzeigenItem auf klicken Sie auf Bild und TextView. bitte helfen Sie mir, meine Menüs anzuzeigenItem. (ich benutze app: actionLayout = "@ layout/login_icon_design"). wenn wir App: actionLayout-Tag entfernen, so dass Menüs kommen.Ich habe Bild und Texview in der Symbolleiste behoben. Jetzt zeigt es keine Menüs
//dashboard.xml file
Code eingeben hier
//login_icon_design.xml
<TextView android:id="@+id/qcId" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:paddingLeft="0dp" android:text="Active" android:textColor="@color/button_green" android:textSize="9dp" />
//DashboardActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.dashboard, menu); final Menu m = menu; final MenuItem mitem = menu.findItem(R.id.button); TextView qcId= (TextView) mitem.getActionView().findViewById(R.id.qcId); SharedPreferences pref=this.getSharedPreferences("MyPref",MODE_PRIVATE); String refCode=pref.getString("refCode",null); qcId.setText(refCode); Intent intent = getIntent(); String str2 = intent.getStringExtra("balance"); menu.findItem(R.id.bal).setTitle("Avl. Bal. \u20B9" +str2); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if(id == R.id.bal) { } else if(id == R.id.profile){ Toast.makeText(this, "1", Toast.LENGTH_SHORT).show(); } else if (id == R.id.logout){ Toast.makeText(this, "2", Toast.LENGTH_SHORT).show(); } else if(id == R.id.event) { Toast.makeText(this, "3", Toast.LENGTH_SHORT).show(); } else if(id == R.id.history) { Toast.makeText(this, "4", Toast.LENGTH_SHORT).show(); } return super.onOptionsItemSelected(item); }
Sie müssen benutzerdefinierte Symbolleiste erstellen. Aber Sie scheinen es zu Standard-Menü Dateiattribut hinzufügen. Sie können es über benutzerdefinierte Menü und Symbolleiste. –