java - MenuItem is not showing up -


i can't menuitem working ,i have created other apps before reason not show :

mainactivity.java

    package ie.example.artur.adminapp;      import android.content.intent;     import android.os.asynctask;     import android.os.bundle;     import android.support.design.widget.floatingactionbutton;     import android.support.design.widget.snackbar;     import android.support.v7.app.appcompatactivity;     import android.support.v7.widget.toolbar;     import android.view.view;     import android.view.menu;     import android.view.menuitem;     import android.view.viewconfiguration;     import android.widget.button;     import android.widget.edittext;     import android.widget.textview;      import java.lang.reflect.field;     import java.sql.connection;     import java.sql.drivermanager;     import java.sql.statement;      public class mainactivity extends appcompatactivity {           edittext edittextname,edittextemail,edittextpassword;         textview textview;         private static final string db_url = "jdbc:mysql://10.3.2.51/socialmedia_website";         private static final string user = "zzz";         private static final string pass = "zzz";            @override         protected void oncreate(bundle savedinstancestate) {             super.oncreate(savedinstancestate);             setcontentview(r.layout.activity_register);             toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar);             setsupportactionbar(toolbar);              textview = (textview) findviewbyid(r.id.textview);             edittextname = (edittext) findviewbyid(r.id.edittextname);             edittextemail = (edittext) findviewbyid(r.id.edittextemail);             edittextpassword = (edittext) findviewbyid(r.id.edittextpassword);     ////        try {     ////            viewconfiguration config = viewconfiguration.get(this);     ////            field menukeyfield = viewconfiguration.class.getdeclaredfield("shaspermanentmenukey");     ////            if (menukeyfield != null) {     ////                menukeyfield.setaccessible(true);     ////                menukeyfield.setboolean(config, false);     ////            }     //        } catch (exception ignored) {     //        }               floatingactionbutton fab = (floatingactionbutton) findviewbyid(r.id.fab);             fab.setonclicklistener(new view.onclicklistener() {                 @override                 public void onclick(view view) {                     snackbar.make(view, "replace own action", snackbar.length_long)                             .setaction("action", null).show();                 }             });         }          public void btnconn(view view) {             send objsend = new send();             objsend.execute("");           }         private class send extends asynctask<string, string, string>      {         string msg = "";         string name = edittextname.gettext().tostring();         string email = edittextemail.gettext().tostring();         string password = edittextpassword.gettext().tostring();          @override         protected void onpreexecute() {             textview.settext("please wait inserting data");         }          @override         protected string doinbackground(string... strings) {             try {                 class.forname("com.mysql.jdbc.driver");                 connection conn = drivermanager.getconnection(db_url, user, pass);                 if (conn == null) {                     msg = "connection goes wrong";                 } else {                     string query = "insert users (name,email,password) values('" + name+"','"+email+"','"+password+"')";                     statement stmt = conn.createstatement();                     stmt.executeupdate(query);                     msg = "inserting successful!!";                  }                  conn.close();          }          catch(         exception e         )          {             msg = "connection goes wrong";             e.printstacktrace();          }          return msg;       }    @override     protected void onpostexecute(string msg) {textview.settext(msg);}        }       @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         {             switch (item.getitemid())             {                 case r.id.action_settings : startactivity (new intent(this, showusers.class));                     break;             }             return super.onoptionsitemselected(item);         }}  } 

menu_main.xml:

 <menu xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:app="http://schemas.android.com/apk/res-auto"         xmlns:tools="http://schemas.android.com/tools"         tools:context="ie.example.artur.adminapp.mainactivity">            <item android:id="@+id/action_settings"             android:title="@string/action_settings"             android:orderincategory="100"             app:showasaction="ifroom|withtext"/>      </menu> 

androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="ie.example.artur.adminapp">      <uses-permission android:name="android.permission.internet"/>      <application         android:allowbackup="true"         android:icon="@mipmap/ic_launcher"         android:label="@string/app_name"         android:supportsrtl="true"         android:theme="@style/theme.appcompat.daynight.noactionbar">         <activity             android:name=".mainactivity"             android:label="@string/app_name">             <intent-filter>                 <action android:name="android.intent.action.main" />                  <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity>     </application>  </manifest> 

i have tried following links fix issue non of them helped :

how force use of overflow menu on devices menu button

menu items not showing on action bar

android - menu item not showing in action bar

add in activity..

 @override public boolean oncreateoptionsmenu(menu menu) {     getmenuinflater().inflate(r.menu.menu_main, menu);     return true; } 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -