How to implement Firebase Recycler Adapter in newer version of Android 3.1 and higher?2019 Community Moderator ElectionShould I actually remove the ValueEventListener?How to get the build/version number of your Android application?setText on button from another activity androidScrolling lagged after applying the typeface in the Recycler view itemsFirebase recycler adapter paginationAdding Social Media Share Logic From Firebase in AndroidFirebase Recycler Adapter with searchviewhow to group all Categories in FlexboxLayoutSearch Firestore query don't show data in RecycleViewHow to insert value from a RecyclerView to MS SQL?Why onBindViewHolder index isn't incrementing in Recycler View?

Can we track matter through time by looking at different depths in space?

Possible to detect presence of nuclear bomb?

What would be the most expensive material to an intergalactic society?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

How to write a chaotic neutral protagonist and prevent my readers from thinking they are evil?

Windows Server Data Center Edition - Unlimited Virtual Machines

Power Strip for Europe

Plausibility of Mushroom Buildings

For which categories of spectra is there an explicit description of the fibrant objects via lifting properties?

What problems would a superhuman have who's skin is constantly hot?

Giving a career talk in my old university, how prominently should I tell students my salary?

What is the generally accepted pronunciation of “topoi”?

Doubts in understanding some concepts of potential energy

What will happen if my luggage gets delayed?

Why does Solve lock up when trying to solve the quadratic equation with large integers?

How many characters using PHB rules does it take to be able to have access to any PHB spell at the start of an adventuring day?

How to resolve: Reviewer #1 says remove section X vs. Reviewer #2 says expand section X

How do spaceships determine each other's mass in space?

What is Tony Stark injecting into himself in Iron Man 3?

Having the player face themselves after the mid-game

Which situations would cause a company to ground or recall a aircraft series?

(Codewars) Linked Lists - Remove Duplicates

Can the alpha, lambda values of a glmnet object output determine whether ridge or Lasso?

Specifying a starting column with colortbl package and xcolor



How to implement Firebase Recycler Adapter in newer version of Android 3.1 and higher?



2019 Community Moderator ElectionShould I actually remove the ValueEventListener?How to get the build/version number of your Android application?setText on button from another activity androidScrolling lagged after applying the typeface in the Recycler view itemsFirebase recycler adapter paginationAdding Social Media Share Logic From Firebase in AndroidFirebase Recycler Adapter with searchviewhow to group all Categories in FlexboxLayoutSearch Firestore query don't show data in RecycleViewHow to insert value from a RecyclerView to MS SQL?Why onBindViewHolder index isn't incrementing in Recycler View?










4















Basically, what I am trying to do is use a FirebaseRecyclerAdapter and populate the RecyclerView with my custom designed CardView. The code for newer versions has been changed and therefore, I tried implementing it but didn't work.
This is the code I use to write a year ago, which worked fine and populated my RecyclerView:



FirebaseRecyclerAdapter<DataClass,DataViewHolder> FBRA= new FirebaseRecyclerAdapter<DataClass, DataViewHolder>(
DataClass,
R.layout.myCardView,
DataViewHolder.class,
databaseReference
)
@Override
protected void populateViewHolder(DataViewHolder viewHolder, DataClass model, int position)
viewHolder.setTitle(model.gettitle());
viewHolder.setDate(model.getDate());

;
myRecyclerView.setAdapter(FBRA);


And now we have to use something like this,
but the problem is this code is not populating my recyclerView (What changes do I need to make here to populate my recyclerView with my cardView?)



@Override
protected void onStart()
super.onStart();

Query query = FirebaseDatabase.getInstance()
.getReference()
.child("Official_Services");

FirebaseRecyclerOptions<ServiceClass> options = new FirebaseRecyclerOptions.Builder<ServiceClass>()
.setQuery(query, ServiceClass.class)
.build();

FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options)

@NonNull
@Override
public ServiceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)

View view = LayoutInflater.from(HomeActivity.this).inflate(R.layout.service_card, parent, false);

return new ServiceViewHolder(view);



@Override
protected void onBindViewHolder(@NonNull ServiceViewHolder holder, int position, @NonNull ServiceClass model)

holder.setServiceName(model.getServiceName());

holder.setServiceCaption(model.getServiceCaption());



;

mServiceList.setAdapter(FBRA);




Here is my ViewHolder class:



public static class ServiceViewHolder extends RecyclerView.ViewHolder 

public ServiceViewHolder(View itemView)

super(itemView);

View mView = itemView;



public void setServiceName(String serviceName)

TextView sName = itemView.findViewById(R.id.serviceName);

sName.setText(serviceName);



public void setServiceCaption(String serviceCaption)

TextView sCaption = itemView.findViewById(R.id.serviceCap);

sCaption.setText(serviceCaption);





And this is my Model class of getters and setters:



public class ServiceClass 

private String serviceName;
private String serviceCode;
private String serviceCaption;
private String serviceIconUrl;

public ServiceClass()


public ServiceClass(String serviceName, String serviceCode, String serviceCaption, String serviceIconUrl)
this.serviceName = serviceName;
this.serviceCode = serviceCode;
this.serviceCaption = serviceCaption;
this.serviceIconUrl = serviceIconUrl;


public String getServiceName()
return serviceName;


public String getServiceCode()
return serviceCode;


public String getServiceCaption()
return serviceCaption;


public String getServiceIconUrl()
return serviceIconUrl;


public void setServiceName(String serviceName)
this.serviceName = serviceName;


public void setServiceCode(String serviceCode)
this.serviceCode = serviceCode;


public void setServiceCaption(String serviceCaption)
this.serviceCaption = serviceCaption;


public void setServiceIconUrl(String serviceIconUrl)
this.serviceIconUrl = serviceIconUrl;


@Override
public String toString()
return "ServiceClass" +
"serviceName='" + serviceName + ''' +
", serviceCode='" + serviceCode + ''' +
", serviceCaption='" + serviceCaption + ''' +
", serviceIconUrl='" + serviceIconUrl + ''' +
'';




Now what changes do I need to do?



Here is my entire java file:



public class HomeActivity extends AppCompatActivity 

private RecyclerView mServiceList;

private FirebaseDatabase mDatabase;

private DatabaseReference myRef;

FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA;

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);

BottomNavigationViewEx bottomNavigationViewEx = findViewById(R.id.navViewBar);

bottomNavigationViewEx.enableAnimation(false);

bottomNavigationViewEx.enableShiftingMode(false);

bottomNavigationViewEx.setTextVisibility(false);

Calligrapher calligrapher = new Calligrapher(this);

calligrapher.setFont(this, "Helvetica.ttf", true);

mServiceList = findViewById(R.id.serviceRV);

mServiceList.setHasFixedSize(true);

mServiceList.setLayoutManager(new LinearLayoutManager(this));

mDatabase = FirebaseDatabase.getInstance();

myRef = mDatabase.getReference().child("Official_Services");



@Override
protected void onStart()
super.onStart();

FBRA.startListening();

Query query = myRef;

FirebaseRecyclerOptions<ServiceClass> options = new FirebaseRecyclerOptions.Builder<ServiceClass>()
.setQuery(query, ServiceClass.class)
.build();

FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options)

@NonNull
@Override
public ServiceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)

View view = LayoutInflater.from(HomeActivity.this).inflate(R.layout.service_card, parent, false);

return new ServiceViewHolder(view);



@Override
protected void onBindViewHolder(@NonNull ServiceViewHolder holder, int position, @NonNull ServiceClass model)

holder.setServiceName(model.getServiceName());

holder.setServiceCaption(model.getServiceCaption());



;

mServiceList.setAdapter(FBRA);







public static class ServiceViewHolder extends RecyclerView.ViewHolder

public ServiceViewHolder(View itemView)

super(itemView);

View mView = itemView;



public void setServiceName(String serviceName)

TextView sName = itemView.findViewById(R.id.serviceName);

sName.setText(serviceName);



public void setServiceCaption(String serviceCaption)

TextView sCaption = itemView.findViewById(R.id.serviceCap);

sCaption.setText(serviceCaption);














share|improve this question




























    4















    Basically, what I am trying to do is use a FirebaseRecyclerAdapter and populate the RecyclerView with my custom designed CardView. The code for newer versions has been changed and therefore, I tried implementing it but didn't work.
    This is the code I use to write a year ago, which worked fine and populated my RecyclerView:



    FirebaseRecyclerAdapter<DataClass,DataViewHolder> FBRA= new FirebaseRecyclerAdapter<DataClass, DataViewHolder>(
    DataClass,
    R.layout.myCardView,
    DataViewHolder.class,
    databaseReference
    )
    @Override
    protected void populateViewHolder(DataViewHolder viewHolder, DataClass model, int position)
    viewHolder.setTitle(model.gettitle());
    viewHolder.setDate(model.getDate());

    ;
    myRecyclerView.setAdapter(FBRA);


    And now we have to use something like this,
    but the problem is this code is not populating my recyclerView (What changes do I need to make here to populate my recyclerView with my cardView?)



    @Override
    protected void onStart()
    super.onStart();

    Query query = FirebaseDatabase.getInstance()
    .getReference()
    .child("Official_Services");

    FirebaseRecyclerOptions<ServiceClass> options = new FirebaseRecyclerOptions.Builder<ServiceClass>()
    .setQuery(query, ServiceClass.class)
    .build();

    FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options)

    @NonNull
    @Override
    public ServiceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)

    View view = LayoutInflater.from(HomeActivity.this).inflate(R.layout.service_card, parent, false);

    return new ServiceViewHolder(view);



    @Override
    protected void onBindViewHolder(@NonNull ServiceViewHolder holder, int position, @NonNull ServiceClass model)

    holder.setServiceName(model.getServiceName());

    holder.setServiceCaption(model.getServiceCaption());



    ;

    mServiceList.setAdapter(FBRA);




    Here is my ViewHolder class:



    public static class ServiceViewHolder extends RecyclerView.ViewHolder 

    public ServiceViewHolder(View itemView)

    super(itemView);

    View mView = itemView;



    public void setServiceName(String serviceName)

    TextView sName = itemView.findViewById(R.id.serviceName);

    sName.setText(serviceName);



    public void setServiceCaption(String serviceCaption)

    TextView sCaption = itemView.findViewById(R.id.serviceCap);

    sCaption.setText(serviceCaption);





    And this is my Model class of getters and setters:



    public class ServiceClass 

    private String serviceName;
    private String serviceCode;
    private String serviceCaption;
    private String serviceIconUrl;

    public ServiceClass()


    public ServiceClass(String serviceName, String serviceCode, String serviceCaption, String serviceIconUrl)
    this.serviceName = serviceName;
    this.serviceCode = serviceCode;
    this.serviceCaption = serviceCaption;
    this.serviceIconUrl = serviceIconUrl;


    public String getServiceName()
    return serviceName;


    public String getServiceCode()
    return serviceCode;


    public String getServiceCaption()
    return serviceCaption;


    public String getServiceIconUrl()
    return serviceIconUrl;


    public void setServiceName(String serviceName)
    this.serviceName = serviceName;


    public void setServiceCode(String serviceCode)
    this.serviceCode = serviceCode;


    public void setServiceCaption(String serviceCaption)
    this.serviceCaption = serviceCaption;


    public void setServiceIconUrl(String serviceIconUrl)
    this.serviceIconUrl = serviceIconUrl;


    @Override
    public String toString()
    return "ServiceClass" +
    "serviceName='" + serviceName + ''' +
    ", serviceCode='" + serviceCode + ''' +
    ", serviceCaption='" + serviceCaption + ''' +
    ", serviceIconUrl='" + serviceIconUrl + ''' +
    '';




    Now what changes do I need to do?



    Here is my entire java file:



    public class HomeActivity extends AppCompatActivity 

    private RecyclerView mServiceList;

    private FirebaseDatabase mDatabase;

    private DatabaseReference myRef;

    FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    BottomNavigationViewEx bottomNavigationViewEx = findViewById(R.id.navViewBar);

    bottomNavigationViewEx.enableAnimation(false);

    bottomNavigationViewEx.enableShiftingMode(false);

    bottomNavigationViewEx.setTextVisibility(false);

    Calligrapher calligrapher = new Calligrapher(this);

    calligrapher.setFont(this, "Helvetica.ttf", true);

    mServiceList = findViewById(R.id.serviceRV);

    mServiceList.setHasFixedSize(true);

    mServiceList.setLayoutManager(new LinearLayoutManager(this));

    mDatabase = FirebaseDatabase.getInstance();

    myRef = mDatabase.getReference().child("Official_Services");



    @Override
    protected void onStart()
    super.onStart();

    FBRA.startListening();

    Query query = myRef;

    FirebaseRecyclerOptions<ServiceClass> options = new FirebaseRecyclerOptions.Builder<ServiceClass>()
    .setQuery(query, ServiceClass.class)
    .build();

    FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options)

    @NonNull
    @Override
    public ServiceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)

    View view = LayoutInflater.from(HomeActivity.this).inflate(R.layout.service_card, parent, false);

    return new ServiceViewHolder(view);



    @Override
    protected void onBindViewHolder(@NonNull ServiceViewHolder holder, int position, @NonNull ServiceClass model)

    holder.setServiceName(model.getServiceName());

    holder.setServiceCaption(model.getServiceCaption());



    ;

    mServiceList.setAdapter(FBRA);







    public static class ServiceViewHolder extends RecyclerView.ViewHolder

    public ServiceViewHolder(View itemView)

    super(itemView);

    View mView = itemView;



    public void setServiceName(String serviceName)

    TextView sName = itemView.findViewById(R.id.serviceName);

    sName.setText(serviceName);



    public void setServiceCaption(String serviceCaption)

    TextView sCaption = itemView.findViewById(R.id.serviceCap);

    sCaption.setText(serviceCaption);














    share|improve this question


























      4












      4








      4


      2






      Basically, what I am trying to do is use a FirebaseRecyclerAdapter and populate the RecyclerView with my custom designed CardView. The code for newer versions has been changed and therefore, I tried implementing it but didn't work.
      This is the code I use to write a year ago, which worked fine and populated my RecyclerView:



      FirebaseRecyclerAdapter<DataClass,DataViewHolder> FBRA= new FirebaseRecyclerAdapter<DataClass, DataViewHolder>(
      DataClass,
      R.layout.myCardView,
      DataViewHolder.class,
      databaseReference
      )
      @Override
      protected void populateViewHolder(DataViewHolder viewHolder, DataClass model, int position)
      viewHolder.setTitle(model.gettitle());
      viewHolder.setDate(model.getDate());

      ;
      myRecyclerView.setAdapter(FBRA);


      And now we have to use something like this,
      but the problem is this code is not populating my recyclerView (What changes do I need to make here to populate my recyclerView with my cardView?)



      @Override
      protected void onStart()
      super.onStart();

      Query query = FirebaseDatabase.getInstance()
      .getReference()
      .child("Official_Services");

      FirebaseRecyclerOptions<ServiceClass> options = new FirebaseRecyclerOptions.Builder<ServiceClass>()
      .setQuery(query, ServiceClass.class)
      .build();

      FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options)

      @NonNull
      @Override
      public ServiceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)

      View view = LayoutInflater.from(HomeActivity.this).inflate(R.layout.service_card, parent, false);

      return new ServiceViewHolder(view);



      @Override
      protected void onBindViewHolder(@NonNull ServiceViewHolder holder, int position, @NonNull ServiceClass model)

      holder.setServiceName(model.getServiceName());

      holder.setServiceCaption(model.getServiceCaption());



      ;

      mServiceList.setAdapter(FBRA);




      Here is my ViewHolder class:



      public static class ServiceViewHolder extends RecyclerView.ViewHolder 

      public ServiceViewHolder(View itemView)

      super(itemView);

      View mView = itemView;



      public void setServiceName(String serviceName)

      TextView sName = itemView.findViewById(R.id.serviceName);

      sName.setText(serviceName);



      public void setServiceCaption(String serviceCaption)

      TextView sCaption = itemView.findViewById(R.id.serviceCap);

      sCaption.setText(serviceCaption);





      And this is my Model class of getters and setters:



      public class ServiceClass 

      private String serviceName;
      private String serviceCode;
      private String serviceCaption;
      private String serviceIconUrl;

      public ServiceClass()


      public ServiceClass(String serviceName, String serviceCode, String serviceCaption, String serviceIconUrl)
      this.serviceName = serviceName;
      this.serviceCode = serviceCode;
      this.serviceCaption = serviceCaption;
      this.serviceIconUrl = serviceIconUrl;


      public String getServiceName()
      return serviceName;


      public String getServiceCode()
      return serviceCode;


      public String getServiceCaption()
      return serviceCaption;


      public String getServiceIconUrl()
      return serviceIconUrl;


      public void setServiceName(String serviceName)
      this.serviceName = serviceName;


      public void setServiceCode(String serviceCode)
      this.serviceCode = serviceCode;


      public void setServiceCaption(String serviceCaption)
      this.serviceCaption = serviceCaption;


      public void setServiceIconUrl(String serviceIconUrl)
      this.serviceIconUrl = serviceIconUrl;


      @Override
      public String toString()
      return "ServiceClass" +
      "serviceName='" + serviceName + ''' +
      ", serviceCode='" + serviceCode + ''' +
      ", serviceCaption='" + serviceCaption + ''' +
      ", serviceIconUrl='" + serviceIconUrl + ''' +
      '';




      Now what changes do I need to do?



      Here is my entire java file:



      public class HomeActivity extends AppCompatActivity 

      private RecyclerView mServiceList;

      private FirebaseDatabase mDatabase;

      private DatabaseReference myRef;

      FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA;

      @Override
      protected void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_home);

      BottomNavigationViewEx bottomNavigationViewEx = findViewById(R.id.navViewBar);

      bottomNavigationViewEx.enableAnimation(false);

      bottomNavigationViewEx.enableShiftingMode(false);

      bottomNavigationViewEx.setTextVisibility(false);

      Calligrapher calligrapher = new Calligrapher(this);

      calligrapher.setFont(this, "Helvetica.ttf", true);

      mServiceList = findViewById(R.id.serviceRV);

      mServiceList.setHasFixedSize(true);

      mServiceList.setLayoutManager(new LinearLayoutManager(this));

      mDatabase = FirebaseDatabase.getInstance();

      myRef = mDatabase.getReference().child("Official_Services");



      @Override
      protected void onStart()
      super.onStart();

      FBRA.startListening();

      Query query = myRef;

      FirebaseRecyclerOptions<ServiceClass> options = new FirebaseRecyclerOptions.Builder<ServiceClass>()
      .setQuery(query, ServiceClass.class)
      .build();

      FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options)

      @NonNull
      @Override
      public ServiceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)

      View view = LayoutInflater.from(HomeActivity.this).inflate(R.layout.service_card, parent, false);

      return new ServiceViewHolder(view);



      @Override
      protected void onBindViewHolder(@NonNull ServiceViewHolder holder, int position, @NonNull ServiceClass model)

      holder.setServiceName(model.getServiceName());

      holder.setServiceCaption(model.getServiceCaption());



      ;

      mServiceList.setAdapter(FBRA);







      public static class ServiceViewHolder extends RecyclerView.ViewHolder

      public ServiceViewHolder(View itemView)

      super(itemView);

      View mView = itemView;



      public void setServiceName(String serviceName)

      TextView sName = itemView.findViewById(R.id.serviceName);

      sName.setText(serviceName);



      public void setServiceCaption(String serviceCaption)

      TextView sCaption = itemView.findViewById(R.id.serviceCap);

      sCaption.setText(serviceCaption);














      share|improve this question
















      Basically, what I am trying to do is use a FirebaseRecyclerAdapter and populate the RecyclerView with my custom designed CardView. The code for newer versions has been changed and therefore, I tried implementing it but didn't work.
      This is the code I use to write a year ago, which worked fine and populated my RecyclerView:



      FirebaseRecyclerAdapter<DataClass,DataViewHolder> FBRA= new FirebaseRecyclerAdapter<DataClass, DataViewHolder>(
      DataClass,
      R.layout.myCardView,
      DataViewHolder.class,
      databaseReference
      )
      @Override
      protected void populateViewHolder(DataViewHolder viewHolder, DataClass model, int position)
      viewHolder.setTitle(model.gettitle());
      viewHolder.setDate(model.getDate());

      ;
      myRecyclerView.setAdapter(FBRA);


      And now we have to use something like this,
      but the problem is this code is not populating my recyclerView (What changes do I need to make here to populate my recyclerView with my cardView?)



      @Override
      protected void onStart()
      super.onStart();

      Query query = FirebaseDatabase.getInstance()
      .getReference()
      .child("Official_Services");

      FirebaseRecyclerOptions<ServiceClass> options = new FirebaseRecyclerOptions.Builder<ServiceClass>()
      .setQuery(query, ServiceClass.class)
      .build();

      FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options)

      @NonNull
      @Override
      public ServiceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)

      View view = LayoutInflater.from(HomeActivity.this).inflate(R.layout.service_card, parent, false);

      return new ServiceViewHolder(view);



      @Override
      protected void onBindViewHolder(@NonNull ServiceViewHolder holder, int position, @NonNull ServiceClass model)

      holder.setServiceName(model.getServiceName());

      holder.setServiceCaption(model.getServiceCaption());



      ;

      mServiceList.setAdapter(FBRA);




      Here is my ViewHolder class:



      public static class ServiceViewHolder extends RecyclerView.ViewHolder 

      public ServiceViewHolder(View itemView)

      super(itemView);

      View mView = itemView;



      public void setServiceName(String serviceName)

      TextView sName = itemView.findViewById(R.id.serviceName);

      sName.setText(serviceName);



      public void setServiceCaption(String serviceCaption)

      TextView sCaption = itemView.findViewById(R.id.serviceCap);

      sCaption.setText(serviceCaption);





      And this is my Model class of getters and setters:



      public class ServiceClass 

      private String serviceName;
      private String serviceCode;
      private String serviceCaption;
      private String serviceIconUrl;

      public ServiceClass()


      public ServiceClass(String serviceName, String serviceCode, String serviceCaption, String serviceIconUrl)
      this.serviceName = serviceName;
      this.serviceCode = serviceCode;
      this.serviceCaption = serviceCaption;
      this.serviceIconUrl = serviceIconUrl;


      public String getServiceName()
      return serviceName;


      public String getServiceCode()
      return serviceCode;


      public String getServiceCaption()
      return serviceCaption;


      public String getServiceIconUrl()
      return serviceIconUrl;


      public void setServiceName(String serviceName)
      this.serviceName = serviceName;


      public void setServiceCode(String serviceCode)
      this.serviceCode = serviceCode;


      public void setServiceCaption(String serviceCaption)
      this.serviceCaption = serviceCaption;


      public void setServiceIconUrl(String serviceIconUrl)
      this.serviceIconUrl = serviceIconUrl;


      @Override
      public String toString()
      return "ServiceClass" +
      "serviceName='" + serviceName + ''' +
      ", serviceCode='" + serviceCode + ''' +
      ", serviceCaption='" + serviceCaption + ''' +
      ", serviceIconUrl='" + serviceIconUrl + ''' +
      '';




      Now what changes do I need to do?



      Here is my entire java file:



      public class HomeActivity extends AppCompatActivity 

      private RecyclerView mServiceList;

      private FirebaseDatabase mDatabase;

      private DatabaseReference myRef;

      FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA;

      @Override
      protected void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_home);

      BottomNavigationViewEx bottomNavigationViewEx = findViewById(R.id.navViewBar);

      bottomNavigationViewEx.enableAnimation(false);

      bottomNavigationViewEx.enableShiftingMode(false);

      bottomNavigationViewEx.setTextVisibility(false);

      Calligrapher calligrapher = new Calligrapher(this);

      calligrapher.setFont(this, "Helvetica.ttf", true);

      mServiceList = findViewById(R.id.serviceRV);

      mServiceList.setHasFixedSize(true);

      mServiceList.setLayoutManager(new LinearLayoutManager(this));

      mDatabase = FirebaseDatabase.getInstance();

      myRef = mDatabase.getReference().child("Official_Services");



      @Override
      protected void onStart()
      super.onStart();

      FBRA.startListening();

      Query query = myRef;

      FirebaseRecyclerOptions<ServiceClass> options = new FirebaseRecyclerOptions.Builder<ServiceClass>()
      .setQuery(query, ServiceClass.class)
      .build();

      FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options)

      @NonNull
      @Override
      public ServiceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)

      View view = LayoutInflater.from(HomeActivity.this).inflate(R.layout.service_card, parent, false);

      return new ServiceViewHolder(view);



      @Override
      protected void onBindViewHolder(@NonNull ServiceViewHolder holder, int position, @NonNull ServiceClass model)

      holder.setServiceName(model.getServiceName());

      holder.setServiceCaption(model.getServiceCaption());



      ;

      mServiceList.setAdapter(FBRA);







      public static class ServiceViewHolder extends RecyclerView.ViewHolder

      public ServiceViewHolder(View itemView)

      super(itemView);

      View mView = itemView;



      public void setServiceName(String serviceName)

      TextView sName = itemView.findViewById(R.id.serviceName);

      sName.setText(serviceName);



      public void setServiceCaption(String serviceCaption)

      TextView sCaption = itemView.findViewById(R.id.serviceCap);

      sCaption.setText(serviceCaption);











      java android firebase firebase-realtime-database firebaseui






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 5:57









      Supa Mega Ducky Momo da Waffle

      2,00651129




      2,00651129










      asked Mar 6 at 14:26









      KaushalKaushal

      266




      266






















          2 Answers
          2






          active

          oldest

          votes


















          2














          In order to be able to display data from the Firebase realtime database you need to start listening for changes and for that you should add the following line of code in the onStart() method:



          @Override
          protected void onStart()
          super.onStart();
          FBRA.startListening();



          To stop listening foir changes you need add the following line of code in the onStop() method like this:



          @Override
          protected void onStop()
          super.onStop();
          if(FBRA != null)
          FBRA.stopListening();




          Please see my answer from this post where I have explained why you should remove the listener.



          P.S. Please also don't forget to make the FBRA a global variable and remove FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> from the declaration of the object.






          share|improve this answer























          • I added FBRA.startListening(); in onStart(), but now the app is crashing.

            – Kaushal
            Mar 6 at 16:22






          • 1





            Change this line FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) with FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) Does it work now?

            – Alex Mamo
            Mar 6 at 16:31






          • 1





            Move this line FBRA.startListening(); after ` mServiceList.setAdapter(FBRA);`, works?

            – Alex Mamo
            Mar 6 at 16:55







          • 1





            Good to hear that it worked! It means that the initial error disappeared and this are good news :) The fact that the serviceName and serviceCaption are not displayed sounds as a new issue which basically should be considered another question that cannot be answered in a comment. As a personal guess, I think that you are using a wrong views but in order to follow the rules of this comunity, please post another fresh question using a MCVE, so me and other Firebase developers can help you.

            – Alex Mamo
            Mar 6 at 17:07






          • 1





            Yup! It was really helpful 😊

            – Kaushal
            Mar 6 at 17:16


















          1














          This is more of an advice. If you want to continue using the old method to populate your
          recyclerview ie The "populateViewHolder" method instead of the new "onBindViewHolder" method just use this;



          implementation 'com.firebaseui:firebase-ui:1.0.1'


          instead of upgraded firebase-ui versions






          share|improve this answer








          New contributor




          Martin Mbae is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.



















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55025409%2fhow-to-implement-firebase-recycler-adapter-in-newer-version-of-android-3-1-and-h%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            In order to be able to display data from the Firebase realtime database you need to start listening for changes and for that you should add the following line of code in the onStart() method:



            @Override
            protected void onStart()
            super.onStart();
            FBRA.startListening();



            To stop listening foir changes you need add the following line of code in the onStop() method like this:



            @Override
            protected void onStop()
            super.onStop();
            if(FBRA != null)
            FBRA.stopListening();




            Please see my answer from this post where I have explained why you should remove the listener.



            P.S. Please also don't forget to make the FBRA a global variable and remove FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> from the declaration of the object.






            share|improve this answer























            • I added FBRA.startListening(); in onStart(), but now the app is crashing.

              – Kaushal
              Mar 6 at 16:22






            • 1





              Change this line FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) with FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) Does it work now?

              – Alex Mamo
              Mar 6 at 16:31






            • 1





              Move this line FBRA.startListening(); after ` mServiceList.setAdapter(FBRA);`, works?

              – Alex Mamo
              Mar 6 at 16:55







            • 1





              Good to hear that it worked! It means that the initial error disappeared and this are good news :) The fact that the serviceName and serviceCaption are not displayed sounds as a new issue which basically should be considered another question that cannot be answered in a comment. As a personal guess, I think that you are using a wrong views but in order to follow the rules of this comunity, please post another fresh question using a MCVE, so me and other Firebase developers can help you.

              – Alex Mamo
              Mar 6 at 17:07






            • 1





              Yup! It was really helpful 😊

              – Kaushal
              Mar 6 at 17:16















            2














            In order to be able to display data from the Firebase realtime database you need to start listening for changes and for that you should add the following line of code in the onStart() method:



            @Override
            protected void onStart()
            super.onStart();
            FBRA.startListening();



            To stop listening foir changes you need add the following line of code in the onStop() method like this:



            @Override
            protected void onStop()
            super.onStop();
            if(FBRA != null)
            FBRA.stopListening();




            Please see my answer from this post where I have explained why you should remove the listener.



            P.S. Please also don't forget to make the FBRA a global variable and remove FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> from the declaration of the object.






            share|improve this answer























            • I added FBRA.startListening(); in onStart(), but now the app is crashing.

              – Kaushal
              Mar 6 at 16:22






            • 1





              Change this line FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) with FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) Does it work now?

              – Alex Mamo
              Mar 6 at 16:31






            • 1





              Move this line FBRA.startListening(); after ` mServiceList.setAdapter(FBRA);`, works?

              – Alex Mamo
              Mar 6 at 16:55







            • 1





              Good to hear that it worked! It means that the initial error disappeared and this are good news :) The fact that the serviceName and serviceCaption are not displayed sounds as a new issue which basically should be considered another question that cannot be answered in a comment. As a personal guess, I think that you are using a wrong views but in order to follow the rules of this comunity, please post another fresh question using a MCVE, so me and other Firebase developers can help you.

              – Alex Mamo
              Mar 6 at 17:07






            • 1





              Yup! It was really helpful 😊

              – Kaushal
              Mar 6 at 17:16













            2












            2








            2







            In order to be able to display data from the Firebase realtime database you need to start listening for changes and for that you should add the following line of code in the onStart() method:



            @Override
            protected void onStart()
            super.onStart();
            FBRA.startListening();



            To stop listening foir changes you need add the following line of code in the onStop() method like this:



            @Override
            protected void onStop()
            super.onStop();
            if(FBRA != null)
            FBRA.stopListening();




            Please see my answer from this post where I have explained why you should remove the listener.



            P.S. Please also don't forget to make the FBRA a global variable and remove FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> from the declaration of the object.






            share|improve this answer













            In order to be able to display data from the Firebase realtime database you need to start listening for changes and for that you should add the following line of code in the onStart() method:



            @Override
            protected void onStart()
            super.onStart();
            FBRA.startListening();



            To stop listening foir changes you need add the following line of code in the onStop() method like this:



            @Override
            protected void onStop()
            super.onStop();
            if(FBRA != null)
            FBRA.stopListening();




            Please see my answer from this post where I have explained why you should remove the listener.



            P.S. Please also don't forget to make the FBRA a global variable and remove FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> from the declaration of the object.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 6 at 14:50









            Alex MamoAlex Mamo

            45.2k82863




            45.2k82863












            • I added FBRA.startListening(); in onStart(), but now the app is crashing.

              – Kaushal
              Mar 6 at 16:22






            • 1





              Change this line FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) with FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) Does it work now?

              – Alex Mamo
              Mar 6 at 16:31






            • 1





              Move this line FBRA.startListening(); after ` mServiceList.setAdapter(FBRA);`, works?

              – Alex Mamo
              Mar 6 at 16:55







            • 1





              Good to hear that it worked! It means that the initial error disappeared and this are good news :) The fact that the serviceName and serviceCaption are not displayed sounds as a new issue which basically should be considered another question that cannot be answered in a comment. As a personal guess, I think that you are using a wrong views but in order to follow the rules of this comunity, please post another fresh question using a MCVE, so me and other Firebase developers can help you.

              – Alex Mamo
              Mar 6 at 17:07






            • 1





              Yup! It was really helpful 😊

              – Kaushal
              Mar 6 at 17:16

















            • I added FBRA.startListening(); in onStart(), but now the app is crashing.

              – Kaushal
              Mar 6 at 16:22






            • 1





              Change this line FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) with FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) Does it work now?

              – Alex Mamo
              Mar 6 at 16:31






            • 1





              Move this line FBRA.startListening(); after ` mServiceList.setAdapter(FBRA);`, works?

              – Alex Mamo
              Mar 6 at 16:55







            • 1





              Good to hear that it worked! It means that the initial error disappeared and this are good news :) The fact that the serviceName and serviceCaption are not displayed sounds as a new issue which basically should be considered another question that cannot be answered in a comment. As a personal guess, I think that you are using a wrong views but in order to follow the rules of this comunity, please post another fresh question using a MCVE, so me and other Firebase developers can help you.

              – Alex Mamo
              Mar 6 at 17:07






            • 1





              Yup! It was really helpful 😊

              – Kaushal
              Mar 6 at 17:16
















            I added FBRA.startListening(); in onStart(), but now the app is crashing.

            – Kaushal
            Mar 6 at 16:22





            I added FBRA.startListening(); in onStart(), but now the app is crashing.

            – Kaushal
            Mar 6 at 16:22




            1




            1





            Change this line FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) with FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) Does it work now?

            – Alex Mamo
            Mar 6 at 16:31





            Change this line FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder> FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) with FBRA = new FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>(options) Does it work now?

            – Alex Mamo
            Mar 6 at 16:31




            1




            1





            Move this line FBRA.startListening(); after ` mServiceList.setAdapter(FBRA);`, works?

            – Alex Mamo
            Mar 6 at 16:55






            Move this line FBRA.startListening(); after ` mServiceList.setAdapter(FBRA);`, works?

            – Alex Mamo
            Mar 6 at 16:55





            1




            1





            Good to hear that it worked! It means that the initial error disappeared and this are good news :) The fact that the serviceName and serviceCaption are not displayed sounds as a new issue which basically should be considered another question that cannot be answered in a comment. As a personal guess, I think that you are using a wrong views but in order to follow the rules of this comunity, please post another fresh question using a MCVE, so me and other Firebase developers can help you.

            – Alex Mamo
            Mar 6 at 17:07





            Good to hear that it worked! It means that the initial error disappeared and this are good news :) The fact that the serviceName and serviceCaption are not displayed sounds as a new issue which basically should be considered another question that cannot be answered in a comment. As a personal guess, I think that you are using a wrong views but in order to follow the rules of this comunity, please post another fresh question using a MCVE, so me and other Firebase developers can help you.

            – Alex Mamo
            Mar 6 at 17:07




            1




            1





            Yup! It was really helpful 😊

            – Kaushal
            Mar 6 at 17:16





            Yup! It was really helpful 😊

            – Kaushal
            Mar 6 at 17:16













            1














            This is more of an advice. If you want to continue using the old method to populate your
            recyclerview ie The "populateViewHolder" method instead of the new "onBindViewHolder" method just use this;



            implementation 'com.firebaseui:firebase-ui:1.0.1'


            instead of upgraded firebase-ui versions






            share|improve this answer








            New contributor




            Martin Mbae is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.
























              1














              This is more of an advice. If you want to continue using the old method to populate your
              recyclerview ie The "populateViewHolder" method instead of the new "onBindViewHolder" method just use this;



              implementation 'com.firebaseui:firebase-ui:1.0.1'


              instead of upgraded firebase-ui versions






              share|improve this answer








              New contributor




              Martin Mbae is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






















                1












                1








                1







                This is more of an advice. If you want to continue using the old method to populate your
                recyclerview ie The "populateViewHolder" method instead of the new "onBindViewHolder" method just use this;



                implementation 'com.firebaseui:firebase-ui:1.0.1'


                instead of upgraded firebase-ui versions






                share|improve this answer








                New contributor




                Martin Mbae is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.










                This is more of an advice. If you want to continue using the old method to populate your
                recyclerview ie The "populateViewHolder" method instead of the new "onBindViewHolder" method just use this;



                implementation 'com.firebaseui:firebase-ui:1.0.1'


                instead of upgraded firebase-ui versions







                share|improve this answer








                New contributor




                Martin Mbae is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer






                New contributor




                Martin Mbae is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered Mar 7 at 4:44









                Martin MbaeMartin Mbae

                216




                216




                New contributor




                Martin Mbae is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Martin Mbae is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Martin Mbae is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55025409%2fhow-to-implement-firebase-recycler-adapter-in-newer-version-of-android-3-1-and-h%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved