title: How to keep menu always on top right corner actionbar
body: <p>I have been developing application Android, I have menu items. But my problem, when I was testing on Samsung Galaxy S4, it is not on the top right corner, but if I was testing with Experia (dimension more shorter than Samsung), it can show on top right corner. How to handle it ? only show first item "Pencarian" with icon, but others doesnt show up.</p>
  
  <p>my menu :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item android:id="@+id/menusearch"
            android:icon="@drawable/searchicon"
            android:title="Pencarian"
            android:showAsAction="ifRoom|collapseActionView"
            android:actionLayout="@layout/search_layout"/&gt;    
      &lt;item android:id="@+id/menuadvancedsearch"
            android:icon="@drawable/searchicon2"
            android:title="Pencarian Advanced"
            android:showAsAction="collapseActionView"/&gt; &lt;!-- pilihan default collpasactionview --&gt;
      &lt;item android:id="@+id/menulogin"
            android:icon="@drawable/usericon"
            android:title="Login"
            android:showAsAction="collapseActionView"/&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>my code :</p>
  
  <pre><code>@Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          //getMenuInflater().inflate(R.menu.tab_sport, menu);
          MenuInflater inflater=getMenuInflater();
          inflater.inflate(R.menu.menu, menu);        
  
          return super.onCreateOptionsMenu(menu);
      }
  
      @SuppressLint("NewApi")
      public boolean onOptionsItemSelected(MenuItem item) {       
          switch(item.getItemId())
          {
              case R.id.menusearch:
                  //Toast.makeText(getBaseContext(), "test", Toast.LENGTH_LONG).show();
  
                  View view = item.getActionView();
                  final EditText edtsearchitem=(EditText)view.findViewById(R.id.edtsearchitem);
                  edtsearchitem.setOnKeyListener(new OnKeyListener() {
  
                      @Override
                      public boolean onKey(View v, int keyCode, KeyEvent event) {
                          // TODO Auto-generated method stub
                          if ((event.getAction() == KeyEvent.ACTION_DOWN) &amp;&amp; (keyCode == KeyEvent.KEYCODE_ENTER)) {
                              // Perform action on key press                                                      
                              //Global.MainActivity.finish();
                              OtherClass.setKeyword(edtsearchitem.getText().toString());
                              OtherClass.setFlagSearch(true);
  
                              Intent MyIntentDetailItem=new Intent(getBaseContext(), SearchActivity.class);                           
                              startActivity(MyIntentDetailItem);  
  
                              return true;
                          }
                          return false;
                      }
                  });
  
                  ImageView imgcross=(ImageView)view.findViewById(R.id.imgcross);
                  imgcross.setOnClickListener(new OnClickListener() {
  
                      public void onClick(View arg0) {
                          // TODO Auto-generated method stub
                          edtsearchitem.setText("");
                      }
                  });
  
                  return true;
              case R.id.menuadvancedsearch:
                  OtherClass.setFlagSearch(false);
  
                  Intent MyIntentDetailItem=new Intent(getBaseContext(), SearchActivity.class);                           
                  startActivity(MyIntentDetailItem);              
                  return true;
              case R.id.menulogin:
                  LayoutInflater li = LayoutInflater.from(MainActivity.this);
                  final View inputdialogcustom = li.inflate(R.layout.custom_user, null);
                  final AlertDialog alert = new AlertDialog.Builder(MainActivity.this).create();
                  alert.setView(inputdialogcustom);
  
                  final EditText edtuser=(EditText)inputdialogcustom.findViewById(R.id.edtuser);
                  final EditText edtpassword=(EditText)inputdialogcustom.findViewById(R.id.edtpassword);
                  Button btnlogin=(Button)inputdialogcustom.findViewById(R.id.btnlogin);
                  Button btncancel=(Button)inputdialogcustom.findViewById(R.id.btncancel);
  
                  btnlogin.setOnClickListener(new OnClickListener() {
  
                      @Override
                      public void onClick(View v) {
                          // TODO Auto-generated method stub
                          connection = new ViewConnection(getBaseContext());
                          if (connection.isConnectingToInternet())
                          {
                              BaseUrl=OtherClass.URLlogin+"?user="+edtuser.getText().toString()+
                                      "&amp;pass="+edtpassword.getText().toString();
                              executeAsyncTask();
                          }else {
  
                              // Internet connection is not present
                              /*LayoutInflater li = LayoutInflater.from(MainActivity.this);
                              final View inputdialogcustom = li.inflate(R.layout.activity_confirm_connection, null);              
                              AlertDialog.Builder alerterror = new AlertDialog.Builder(MainActivity.this);                                                
                              alerterror.setView(inputdialogcustom);      
  
                              alerterror.setPositiveButton("OK", new DialogInterface.OnClickListener() { 
                                  @Override
                                  public void onClick(DialogInterface dialog, int which) {                                
                                      System.exit(0);
                                  }
                              }); 
                              alerterror.show();*/
                              Toast.makeText(getBaseContext(), "Tidak ada koneksi internet", Toast.LENGTH_SHORT).show();
                          }
                      }
                  });
                  btncancel.setOnClickListener(new OnClickListener() {
  
                      @Override
                      public void onClick(View arg0) {
                          // TODO Auto-generated method stub
                          alert.dismiss();
                      }
                  });
  
                  alert.show();
  
                  return true;
              default:
                  return super.onOptionsItemSelected(item);
          }       
      }
  </code></pre>