title: Pop up window from menu overflow item selected android
body: <p>I am trying to display a pop up window when i click on a menu overflow item. I have written some code also for that. But it outputs nothing. </p>
  
  <p>Here is some code:</p>
  
  <pre><code>@Override
  public boolean onOptionsItemSelected(MenuItem item){
      switch (item.getItemId()) {
      case R.id.settings_id: 
          displayPopupWindow();
          return true;
  
      case R.id.about_us_id:
  
          return true;
  
          case R.id.logout_id:
          startActivity(new Intent(HomePage.this,MainActivity.class));
          return true;
  
      default:
          return super.onOptionsItemSelected(item);
      } 
  }
  
  public void displayPopupWindow() {
  PopupWindow popup = new PopupWindow(this);
  View layout = getLayoutInflater().inflate(R.layout.popup, null);
  popup.setContentView(layout);
  popup.setOutsideTouchable(true);
  popup.setFocusable(true);
  popup.showAtLocation(layout, Gravity.CENTER, 0, 0);
  
  }
  </code></pre>
  
  <p>My Xml file Code is below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent" android:layout_height="match_parent"
  android:background="@color/colorPrimary"&gt;
  
  &lt;TextView
      android:text="TextView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="165dp"
      android:id="@+id/textView"
      tools:text="This is a Pop Up Window!"
      android:textSize="36sp"
      android:textStyle="normal|bold"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_marginLeft="19dp"
      android:layout_marginStart="19dp"
      android:textAlignment="center"
      android:fontFamily="sans-serif" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Where is the error? Please help me.</p>