title: Is it possible to use ActionBar in popup window
body: <p>In my Class which extends ListFragment I have a popup window which shows when I click one button. My problem is I don't know if I can use ActionBar in it. I mean I want to get an back arrow and it should close (dismiss) popup when it gets clicked. I mean: something like this:</p>
  <pre><code>    toolbar = findViewById(R.id.tool_bar);
      setSupportActionBar(toolbar);
      getSupportActionBar().setTitle(&quot;Enter transaction&quot;);
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  </code></pre>
  <p>Is such functionality even possible? Or rather should I use customizable toolbar with added ImageView use set listener to close popup? Or maybe I should create custom Dialog?</p>
  <p>I'm attaching a file which shows what I have now and want I want to achieve.
  <a href="https://i.stack.imgur.com/TTF5H.jpg" rel="nofollow noreferrer">image</a></p>
  <p>This is fragment of my class</p>
  <pre><code>public class LastTransactionsFragment extends ListFragment implements, View.OnClickListener{
  
      //popupWindow
      private View popupView;
      private Button chooseTransactionDate;
      private Button chooseTodayTomorrow;
      private RadioGroup chooseTransactionType;
      private RadioButton chosenTransactionExpense;
      private RadioButton chosenTransactionIncome;
      private ImageView transactionCategoryImage;
      private Spinner chooseTransactionCategory;
      private EditText chooseTransactionAmount;
      private EditText chooseTransactionName;
      private Button saveTransactionButton;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      }
  
      @RequiresApi(api = Build.VERSION_CODES.N)
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          view = inflater.inflate(R.layout.fragment_last_transactions, container, false);
  
          addTransactionActionButton = view.findViewById(R.id.add_transaction_action_button);
          addTransactionActionButton.setOnClickListener(this);
  
          return view;
      }
  
  
      @RequiresApi(api = Build.VERSION_CODES.N)
      @Override
      public void onClick(View v) {
          switch (v.getId()) {
  
              case R.id.add_transaction_action_button: {
                  // inflate the layout of the popup window
                  LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(LAYOUT_INFLATER_SERVICE);
                  popupView = inflater.inflate(R.layout.activity_transaction, null);
  
                  PopupWindow popupWindow = new PopupWindow(popupView, 565, 760, true);
                  popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
  
                  Toolbar toolbar = popupView.findViewById(R.id.tool_bar);
                  toolbar.setTitleTextColor(Color.WHITE);
                  toolbar.setTitle(&quot;New transaction&quot;);
  
                  int currentDay = 1;
                  int currentMonth = Integer.parseInt(actualChosenMonth.getText().toString().substring(0, 2)) - 1;
                  int currentYear = Integer.parseInt(actualChosenMonth.getText().toString().substring(3, 7));
                  SimpleDateFormat simpledateformat = new SimpleDateFormat(&quot;EE&quot;);
                  Date date = new Date(currentYear, currentMonth, currentDay - 1);
                  String currentDayOfWeek = simpledateformat.format(date);
                  String currentDateAsString = convertDateToString(currentDay, currentMonth, currentYear, currentDayOfWeek);
  
                  chooseTransactionDate = popupView.findViewById(R.id.chooseTransactionDate);
                  chooseTransactionDate.setText(currentDateAsString);
                  chooseTransactionDate.setOnClickListener(this);
  
  //I cut rest of of listener 
  
                  saveTransactionButton = popupView.findViewById(R.id.saveTransactionButton);
                  saveTransactionButton.setOnClickListener(this);
                  break;
              }
  
  
              default:
                  break;
          }
      }
  </code></pre>
  <p>And this is my layout file (with custom toolbar)</p>
  <pre><code>    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:background=&quot;@color/bacgroundColorPopup&quot;
      tools:context=&quot;.TransactionActivity&quot;&gt;
  
      &lt;include
          android:id=&quot;@+id/tool_bar&quot;
          layout=&quot;@layout/tool_bar&quot; /&gt;
  
      &lt;Button
          android:id=&quot;@+id/saveTransactionButton&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;45dp&quot;
          android:layout_below=&quot;@+id/chooseTransactionName&quot;
          android:layout_centerInParent=&quot;true&quot;/&gt;
  
  //I cut rest of layout
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>