FirebaseListAdapter not pushing individual items for chat app - Firebase-Ui 3.1
To let the FirebaseRecyclerAdapter and FirebaseListAdapter show the data on the activity
You need to use this:
@Override
protected void onStart() {
super.onStart();
adapter.startListening();
}
@Override
protected void onStop() {
super.onStop();
adapter.stopListening();
}
Since FirebaseListAdapter
uses a listener to check for changes in the firebase database, then to being listening for data you need to add adapter.startListening()
inside the onStart()
to be able to show the data in the listview.
Then inside onStop()
(when activity is stopped), you can use adapter.stopListening()
to remove the listener and the data in the adapter.
Check this for more info: Adapter LifeCycle
Note:
If after using the above, you get a nullpointexception
or cannot resolve symbol
, you have to declare adapter
as global variable and please check the below answer: Error in startListening()
Firebase list adapter doesn't work shows error.......when try to initialize it?
In version 3.x.x of FirebaseUI, adapters are initialized differently from previous versions. This is noted in the upgrade documentation and described here.
Change your code to this:
FirebaseListOptions<Boxer> options = new FirebaseListOptions.Builder<Boxer>()
.setQuery(databaseReference, Boxer.class)
.build();
fireBaseListAdapter = new FirebaseListAdapter<Boxer>(options) {
@Override
protected void populateView(View view, Boxer model, int position) {
...
}
};
RecyclerView using FirebaseRecyclerAdapter is not displaying items - FirebaseUI (3.1.3)
Peter Hadad's answer worked for me here:
Android ListView adapter not pushing individual items for chat app - Firebase-Ui 3.1
, so You need to use this:
@Override
protected void onStart() {
super.onStart();
adapter.startListening();
}
@Override
protected void onStop() {
super.onStop();
adapter.stopListening();
}
Since FirebaseListAdapter
uses a listener to check for changes in the firebase database, then to being listening for data you need to add adapter.startListening()
inside the onStart()
to be able to show the data in the listview.
Then inside onStop()
, you can use adapter.stopListening()
to remove the listener and the data from the adapter.
Firebase ui 3.1.0 (Firebaselistadapter) No setter/field for mc_name found on class
after looking over and over I noticed this in logcat
"No setter/field for mc_name found on class"
I've fixed the problem. It was in the model class getName() and SetName() methods I changed them to same name as the child key name in my firebase you can see picture of the database in the question above. so the new methods are getMc_name() and setMc_name().
public class Sub_Category_Data {
private String mc_name;
private String url;
public Sub_Category_Data() {
}
public String getMc_name() {
return mc_name;
}
public void setMc_name(String mc_name) {
this.mc_name = mc_name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
the output screen shot
Firebase RecyclerView UI not showing
You need to add the following:
The
FirebaseRecyclerAdapter
uses an event listener to monitor changes to the Firebase query. To begin listening for data, call thestartListening()
method. You may want to call this in youronStart()
method. Make sure you have finished any authentication necessary to read the data before callingstartListening()
or your query will fail.
@Override
protected void onStart() {
super.onStart();
firebaseRecyclerAdapter.startListening();
}
@Override
protected void onStop() {
super.onStop();
firebaseRecyclerAdapter.stopListening();
}
more info here:
https://github.com/firebase/FirebaseUI-Android/tree/master/database
Firebase recycler adapter not functioning
The FirebaseRecyclerAdapter
uses an event listener to monitor changes to the Firebase query. To begin listening for data, call the startListening()
method. Make sure you have finished any authentication necessary to read the data before calling startListening()
or your query will fail.
So seems only you need is to call TestAdapter.startListening();
in onStart()
method and don't forget to call TestAdapter.stopListening();
in onStop()
as well but before calling stopListening()
always check agains null
like:if(TestAdapter != null)
For more information and example: https://github.com/firebase/FirebaseUI-Android/blob/master/database/README.md
FirebaseRecyclerAdapter unable to populate result
To solve this, first make your adapter variable global:
private FirebaseRecyclerAdapter<UserInformation, EmployeeViewHolder> adapter;
Then you need to add the following lines of code in your onStart()
and onStop()
methods:
@Override
protected void onStart() {
super.onStart();
adapter.startListening();
}
@Override
protected void onStop() {
super.onStop();
if(adapter != null) {
adapter.stopListening();
}
}
Because the adapter uses a listener to check for database changes, in order to make it work, we need to start listening first. And when we close the application, we need to stop listening.
I have explained in one of my videos, how to achieve this, step by step.
Android FirebaseRecyclerAdapter is not populating RecyclerView
add this line:
firebaseRecyclerAdapter.startListening();
under this:
mRecyclerView.setAdapter(firebaseRecyclerAdapter);
inside searchFriends() method.
Related Topics
How to Call a Method After a Delay in Android
Check Orientation on Android Phone
Populating a Listview Using an Arraylist
How to Run a Command At Terminal from Java Program
How to Create a Generic Array in Java
Loop Doesn't See Value Changed by Other Thread Without a Print Statement
Why Don't Java'S +=, -=, *=, /= Compound Assignment Operators Require Casting
How Does Java Handle Integer Underflows and Overflows and How Would You Check For It
Error - Trustanchors Parameter Must Be Non-Empty
Why Is Super.Super.Method(); Not Allowed in Java
What's the Best Way to Share Data Between Activities
Android: How to Use Alarmmanager
Execution Failed For Task :App:Compiledebugjavawithjavac in Android Studio
Eclipse/Tomcat: Deploy Doesn't Work Any More (Classnotfoundexception)
Int Division: Why Is the Result of 1/3 == 0
How to Add Local Jar Files to a Maven Project
Error Java.Lang.Outofmemoryerror: Gc Overhead Limit Exceeded