title: How do I populate a ListView with data from Firebase?
body: <pre><code>ListView listView = (ListView) findViewById(R.id.listView);
      final ArrayList&lt;String&gt; friends = new ArrayList&lt;String&gt;();
      players.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              for (DataSnapshot player : dataSnapshot.getChildren()) {
                  Log.i("player", player.getKey());
                  friends.add(player.getKey());
  
              }
          }
  
          @Override
          public void onCancelled(FirebaseError firebaseError) {
  
          }
      });
  
      while (friends.isEmpty()) {
          try {
              Thread.sleep(1000);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
      }
  
          // link between a set of data and the AdapterView that displays the data
          ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1,
                  friends);
          listView.setAdapter(arrayAdapter);
  </code></pre>
  
  <p>I expected that it would make the current thread wait until Firebase's thread acquires all the data and stores it into friends array list, but I only get black screen on my Android emulator.
  Could anyone give any suggestions as to how I could accomplish this task?</p>