title: ListView items don't display immediately on startup
body: <p>I have a strange glitch with my program. I'm trying to follow a <a href="https://www.youtube.com/watch?v=AXmiZl03Rb4&amp;index=11&amp;list=PLfBjz1j1UV9m3MofrgMivwaGjRjfhMQfL" rel="nofollow noreferrer">tutorial</a> in regards to generating and displaying listView items using firebase.</p>
  
  <p>The problem with my program is that on start up I cannot see any of my list items however when I start to create a new item the list populates itself with all my previous entries and my newly created one.</p>
  
  <p>From my research on similar problems there has been talk of using notifydatasetchanged to update my listview however some people have said that when calling an ArrayAdapter there is no need to do this as data is constantly being updated. </p>
  
  <pre><code>**CustomAdapter Class**
  
  /**
   * Created by MarkB on 14/03/2017.
   */
  
  public class CustomAdapter extends BaseAdapter {
      Context c;
      ArrayList&lt;User&gt; users;
  
      public CustomAdapter (Context c, ArrayList&lt;User&gt; users) {
          this.c = c;
          this.users = users;
      }
  
      @Override
      public int getCount() {
          return users.size();
      }
  
      @Override
      public Object getItem(int position) {
          return users.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup viewGroup) {
          if (convertView==null)
          {
              convertView = LayoutInflater.from(c).inflate(R.layout.model,viewGroup,false);
          }
  
          //Find TextView items on the model.xml
          TextView nameTxt = (TextView) convertView.findViewById(R.id.nameTxt);
          TextView surnameTxt = (TextView) convertView.findViewById(R.id.surnameTxt);
          TextView ageTxt = (TextView) convertView.findViewById(R.id.ageTxt);
          TextView weightTxt = (TextView) convertView.findViewById(R.id.weightTxt);
          TextView genderTxt = (TextView) convertView.findViewById(R.id.genderTxt);
  
          final User u = (User) this.getItem(position);
  
          nameTxt.setText(u.getName());
          surnameTxt.setText(u.getSurname());
          ageTxt.setText(u.getAge());
          weightTxt.setText(u.getWeight());
          genderTxt.setText(u.getGender());
  
          //ONITEMCLICK
          convertView.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  Toast.makeText(c,"Hi " + u.getName(), Toast.LENGTH_SHORT).show();
  
                  Intent startMenuActivity = new Intent(c, Menu_Activity.class);
                  c.startActivity(startMenuActivity);
              }
          });
  
          return convertView;
      }
  }
  </code></pre>
  
  <p>**Home_Screen_Activity Class*</p>
  
  <pre><code>public class Home_Screen_Activity extends AppCompatActivity {
  
      DatabaseReference db;
      FirebaseHelper helper;
      CustomAdapter adapter;
      ListView lv;
      EditText nameTxt, surnameTxt, ageTxt, weightTxt;
      Spinner genderSpinner;
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_home_screen);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          lv = (ListView) findViewById(R.id.listView);
  
          //INITIALISE FIREBASE DB
          db = FirebaseDatabase.getInstance().getReference();
          helper = new FirebaseHelper(db);
  
          //ADAPTER
          adapter = new CustomAdapter(this, helper.retrieve());
          lv.setAdapter(adapter);
  
          FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
          fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  displayInputDialog();
              }
  
          });
      }
  
      //DISPLAY INPUT DIALOG
      private void displayInputDialog() {
          final Dialog d = new Dialog(this);
          d.setTitle("Save To Firebase");
          d.setContentView(R.layout.input_dialog);
  
          nameTxt = (EditText) d.findViewById(R.id.nameEditText);
          surnameTxt = (EditText) d.findViewById(R.id.surnameEditText);
          ageTxt = (EditText) d.findViewById(R.id.ageEditText);
          weightTxt = (EditText) d.findViewById(R.id.weightEditText);
          genderSpinner = (Spinner) d.findViewById(R.id.genderSpinner);
  
          Button saveBtn = (Button) d.findViewById(R.id.saveBtn);
  
          saveBtn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  //GET DATA
                  String name = nameTxt.getText().toString();
                  String surname = surnameTxt.getText().toString();
                  String age = ageTxt.getText().toString();
                  String weight = weightTxt.getText().toString();
                  String gender = genderSpinner.getSelectedItem().toString();
  
  
                  //SET DATA
                  User u = new User();
                  u.setName(name);
                  u.setSurname(surname);
                  u.setAge(age);
                  u.setWeight(weight);
                  u.setGender(gender);
  
                  //SIMPLE VALIDATION
                  if (name != null &amp;&amp; name.length() &gt; 0) {
                      //THEN SAVE
                      if (helper.save(u)) {
                          //IF SAVED CLEAR EDITTXT
                          nameTxt.setText("");
                          surnameTxt.setText("");
                          ageTxt.setText("");
                          weightTxt.setText("");
                          genderSpinner.setSelection(0);
  
  
                          adapter = new CustomAdapter(Home_Screen_Activity.this, helper.retrieve());
                          lv.setAdapter(adapter);
  
                          d.dismiss();
                      }
                  }
                  else
                  {
                      Toast.makeText(Home_Screen_Activity.this, "Name Must Not Be Empty", Toast.LENGTH_SHORT).show();
                  }
              }
          });
          d.show();
      }
  }
  </code></pre>
  
  <p>Any help is appreciated. I honestly don't understand where this glitch is coming from. There is no mention of this glitch in my logcat either</p>