title: Can't I use different fragments at the same time using one button on the main?
body: <p>First, here is my code. I have 3 Fragments, also have two buttons(<code>saveButton</code>, <code>deleteButton</code>) in <code>MainActivity</code>. If I press <code>Fragment A</code> and press the Save button, the dialogue will come out. Entering the name of <code>Fragment</code> on the Dialogue changes the title of <code>Fragment A</code>. The problem is that if I do this, did't change Fragment A,b,c title only C change. change title A, B -&gt; change title C.... how can i separate one save button in each fragment? Is that possible??</p>
  <pre><code>   ((MainActivity)getActivity()).btn_save.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              save_title = new EditText(getActivity());
              AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
              builder.setTitle(&quot;서식 저장&quot;);
              builder.setMessage(&quot;서식명을 입력해주세요&quot;);
              builder.setView(save_title);
  
              builder.setPositiveButton(&quot;저장&quot;,
                      new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
                              if ((((MainActivity) getActivity()).value) == 1) {
                                  String text = save_title.getText().toString();
                                  sharedPreferences = getActivity().getSharedPreferences(&quot;file&quot;, MODE_PRIVATE);
                                  SharedPreferences.Editor editor = sharedPreferences.edit();
                                  editor.putString(&quot;form1_title&quot;, text);
                                  ((MainActivity) getActivity()).form_button1.setText(text);
                                  editor.apply();
                                  Toast.makeText(getActivity(), &quot;저장 완료&quot;, Toast.LENGTH_SHORT).show();
                              }
                          }
                      });
  
              builder.setNegativeButton(&quot;취소&quot;, new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                  }
              });
              builder.show();
          }
      });
      ((MainActivity)getActivity()).btn_delete.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              fragment1 = new Frag1();
              AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  
              builder.setMessage(&quot;삭제하시겠습니까?&quot;);
              builder.setPositiveButton(&quot;삭제&quot;,
                      new DialogInterface.OnClickListener() {
                          @SuppressLint(&quot;CommitTransaction&quot;)
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
                              if ((((MainActivity) getActivity()).value) == 1) {
                                  getFragmentManager().beginTransaction().replace(R.id.frame, fragment1).commit();
                                  sharedPreferences = getActivity().getSharedPreferences(&quot;file&quot;, MODE_PRIVATE);
                                  SharedPreferences.Editor editor = sharedPreferences.edit();
                                  editor.remove(&quot;form1_title&quot;);
                                  editor.apply();
                              }
                          }
                      });
  
              builder.setNegativeButton(&quot;취소&quot;, new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
  
                  }
              });
              builder.show();
  
          }
  
      });
  </code></pre>