You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -271,7 +271,7 @@ Warning: if you end up making this `ChatMessage` an inner class of another class
271
271
272
272
With the layout for the message specified and their structure defined in a class, we need to make a space for them in the `main_activity.xml`
273
273
274
-
Add a ListView with `android:id="@android:id/list"`` above the LinearLayout:
274
+
Add a ListView with `android:id="@android:id/list"` above the LinearLayout:
275
275
276
276
```xml
277
277
<ListView
@@ -285,18 +285,12 @@ This is the container that all messages will be added to: one message_layout for
285
285
286
286

287
287
288
-
The `id` value is very important here, since Android's `ListActivity` uses it to find the `ListView`. So make sure to enter it exactly as specified: ``@android:id/list`.
289
-
290
-
Make the `MainActivity` class descend from `ListActivity`. This is a built-in Android base-class. By deriving from this, our activity will automatically have access to the ListView we added to the layout:
291
-
292
-
```java
293
-
publicclassMainActivityextendsListActivity {
294
-
```
288
+
The `id` value is very important here, since we'll use it to look up this list before we populate it with items.
295
289
296
290
We're ready to start on our ListAdapter, which we'll base on the `FirebaseListAdapter` from the firebase-ui project we imported. `The FirebaseListAdapter` class adapts a Firebase collection so that it becomes usable in an Android `ListView`. First we'll add a member to our `MainActivity`:
297
291
298
292
```java
299
-
publicclassMainActivityextendsListActivity {
293
+
publicclassMainActivityextendsAppCompatActivity {
300
294
privateFirebase mFirebaseRef;
301
295
FirebaseListAdapter<ChatMessage> mListAdapter;
302
296
```
@@ -306,6 +300,7 @@ public class MainActivity extends ListActivity {
306
300
To make everything come together, we add this to the onCreate method of our MainActivity:
307
301
308
302
```java
303
+
final ListView listView = (ListView) this.findViewById(android.R.id.list);
TheFirebaseListAdapter maps the data from your Firebase database into the ListView that you added to the layout. It creates a new instance of your `two_line_list_item` for each `ChatMessage` and calls the `populateView` method. We override this method and put the name and text in the correct subviews.
@@ -462,7 +457,7 @@ Wrap-up
462
457
463
458
Congratulations! You've just built a fully functional multi-user chat application that uses Firebase to store the data and authentication users.
As a reward for finishing the codelab you’ve earned a promo code!When you’re ready to put your Firebase app in production, you can use the promo code `androidcodelab49` for $49 off your first month of a paid Firebase plan. Just enter the code when you upgrade your Firebase.
0 commit comments