title: Recyclerview updates when I click EditText and removes typo input
body: <p>So when I click my <code>EditText</code> field called <code>Search</code>, I get the keyboard, and for a brief second I see the vatical line you see when you are typing. But then the <code>recyclerview</code> is updated, and the typo input is removed, and the keyboard is still showing, but when I type nothing happens, until I click on the <code>EditText</code> field a second time. How can this be??</p>
  <p><a href="https://i.stack.imgur.com/7FvBx.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7FvBx.gif" alt="EditText" /></a></p>
  <p>This is my Fragment where I have the <code>Recyclerview &amp; EditText</code></p>
  <pre class="lang-java prettyprint-override"><code>
  public class FragmentST extends Fragment {
      private final static String TAG = FragmentST.class.getSimpleName();
      private FloatingActionButton addP, searchP;
      private FirebaseFirestore firestore;
      String editName, editNumber;
      EditText textN, textID, searchText;
      //https://www.youtube.com/watch?v=b_tz8kbFUsU&amp;ab_channel=TVACStudio
      public RecyclerView mResultList;
      public FirestoreRecyclerAdapter adapter;
  
      @Nullable
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_st, container, false);
  
          firestore = FirebaseFirestore.getInstance();
          addP = (FloatingActionButton) view.findViewById(R.id.addP);
          searchP = (FloatingActionButton) view.findViewById(R.id.searchP);
          mResultList = (RecyclerView) view.findViewById(R.id.patientResults);
          searchText = (EditText) view.findViewById(R.id.search_field);
          setPatientView();
          addPatientOnClick();
          search();
  
          return view;
      }
  
      private class PViewHolder extends RecyclerView.ViewHolder {
  
          private TextView List_name, List_cpr;
          private ImageView icon;
  
          public PViewHolder(@NonNull View itemView) {
              super(itemView);
              List_name = itemView.findViewById(R.id.Pname);
              List_cpr = itemView.findViewById(R.id.Pcpr);
              icon = itemView.findViewById(R.id.pb);
          }
      }
  
      private void setPatientView() {
          //Query --&gt;https://www.youtube.com/watch?v=cBwaJYocb9I&amp;ab_channel=TVACStudio
          Query query = firestore.collection(&quot;patients&quot;);
          Log.d(TAG, &quot;setPatientView: &quot; + query);
          //RecyclerOptions
          FirestoreRecyclerOptions&lt;users&gt; options = new FirestoreRecyclerOptions.Builder&lt;users&gt;()
                  .setQuery(query, users.class)
                  .build();
  
          adapter = new FirestoreRecyclerAdapter&lt;users, PViewHolder&gt;(options) {
              @NonNull
              @Override
              public PViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                  View view1 = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_patients_layout, parent, false);
                  return new PViewHolder(view1);
              }
  
              @Override
              protected void onBindViewHolder(@NonNull PViewHolder holder, int position, @NonNull users model) {
                  holder.List_name.setText(model.getName());
                  holder.List_cpr.setText(&quot;CPR: &quot; + model.getCpr());
                  System.out.println(&quot;last character: &quot; + model.getCpr().substring(model.getCpr().length() - 1));
                  if ((Integer.parseInt(model.getCpr().substring(model.getCpr().length() - 1)) % 2) == 0) {
                      // number is even
                      int id = getResources().getIdentifier(&quot;com.example.wrd:drawable/female&quot;, null, null);
                      holder.icon.setImageResource(id);
                  } else {
                      // number is odd
                      int id = getResources().getIdentifier(&quot;com.example.wrd:drawable/male&quot;, null, null);
                      holder.icon.setImageResource(id);
                  }
              }
          };
          mResultList.setHasFixedSize(true);
          mResultList.setLayoutManager(new LinearLayoutManager(getActivity()));
          mResultList.setAdapter(adapter);
      }
  
      private void search() {
          searchP.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Toast.makeText(getActivity(), &quot;HELLO &quot;+searchText.getText().toString(), Toast.LENGTH_SHORT).show();
              }
          });
  
      }
  
      private void addPatientOnClick() {
          addP.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Toast.makeText(getActivity(), &quot;Button Clicked&quot;, Toast.LENGTH_SHORT).show();
                  //https://stackoverflow.com/questions/23669296/create-a-alertdialog-in-android-with-custom-xml-view
                  // custom dialog
                  final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Material_Light_NoActionBar_Fullscreen);
                  dialog.setContentView(R.layout.fragment_add_patient);
                  dialog.setTitle(&quot;Add patient&quot;);
  
                  // set the custom dialog components - text, button
                  TextView text = (TextView) dialog.findViewById(R.id.text);
                  text.setText(&quot;Name&quot;);
                  TextView text2 = (TextView) dialog.findViewById(R.id.text2);
                  text2.setText(&quot;ID&quot;);
  
                  Button dialogButtonOk = (Button) dialog.findViewById(R.id.dialogButtonOK);
                  Button dialogButtonCancel = (Button) dialog.findViewById(R.id.dialogButtonCancel);
                  // if button is clicked, close the custom dialog
                  dialogButtonOk.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          textN = (EditText) dialog.findViewById(R.id.editName);
                          textID = (EditText) dialog.findViewById(R.id.editNumber);
                          editName = textN.getText().toString();
                          editNumber = textID.getText().toString();
                          editNumber.length();
                          if (editNumber != null &amp;&amp; editNumber.length() &gt; 9) {
                              Log.d(TAG, &quot;dialog: \ncpr: &quot; + editNumber);
                          } else {
                              return;
                          }
                          if (editName.matches(&quot;&quot;)) {
                              return;
                          } else {
                              Log.d(TAG, &quot;dialog: \n Name: &quot; + editName);
                          }
                          DocumentReference documentReference = firestore.collection(&quot;patients&quot;).document(editNumber);
                          Map&lt;String, Object&gt; patient = new HashMap&lt;&gt;();
                          patient.put(&quot;name&quot;, editName);
                          patient.put(&quot;cpr&quot;, editNumber);
                          documentReference.set(patient).addOnSuccessListener(new OnSuccessListener&lt;Void&gt;() {
                              @Override
                              public void onSuccess(Void aVoid) {
                                  dialog.dismiss();
                              }
                          }).addOnFailureListener(new OnFailureListener() {
                              @Override
                              public void onFailure(@NonNull Exception e) {
                              }
                          });
  
                      }
                  });
  
                  dialogButtonCancel.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          dialog.dismiss();
                      }
                  });
  
                  dialog.show();
              }
          });
      }
  
      @Override
      public void onDestroy() {
          super.onDestroy();
      }
  
      @Override
      public void onStop() {
          super.onStop();
          adapter.stopListening();
      }
  
      @Override
      public void onStart() {
          super.onStart();
          adapter.startListening();
      }
  
      @Override
      public void onPause() {
          super.onPause();
      }
  
      @Override
      public void onResume() {
          super.onResume();
      }
  }
  </code></pre>
  <p>In the <code>XML</code> the <code>EditText</code> is set to the following</p>
  <pre class="lang-java prettyprint-override"><code>    &lt;EditText
          android:id=&quot;@+id/search_field&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginStart=&quot;15dp&quot;
          android:layout_marginLeft=&quot;15dp&quot;
          android:layout_marginEnd=&quot;10dp&quot;
          android:layout_marginRight=&quot;10dp&quot;
          android:background=&quot;@drawable/search_layout&quot;
          android:ems=&quot;10&quot;
          android:hint=&quot;Search&quot;
          android:inputType=&quot;textPersonName&quot;
          android:paddingLeft=&quot;20dp&quot;
          android:paddingTop=&quot;10dp&quot;
          android:paddingRight=&quot;20dp&quot;
          android:paddingBottom=&quot;10dp&quot;
          android:textSize=&quot;16sp&quot;
          android:layout_weight=&quot;1&quot;
          app:layout_constraintBottom_toBottomOf=&quot;@+id/searchP&quot;
          app:layout_constraintEnd_toStartOf=&quot;@+id/searchP&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;@+id/searchP&quot; /&gt;
  </code></pre>