S
S
suda9112016-12-04 17:09:53
Java
suda911, 2016-12-04 17:09:53

Getting data data from server and display in RecyclerView?

Hello. There is a desire to make an application with a server, but this is not about that now. Interested in how to display data received from a remote database in the application. There is a RecyclerView, an abstract object model (which will be displayed in a separate Cardview) with getters and setters. I read that you need to use the Retrofit 2 library. I read the documentation for it. I realized that the answer should be my class with an object model. But then I don’t understand how to throw this data into RecView and display it? I read that you need to cache, but I don’t understand how .. Can you tell me or throw off an example?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael Kim, 2016-12-04
@suda911

In order to populate the RecyclerView, you need a so-called adapter. You can use primitive built-in adapters or write your own. The adapter takes the data that you need to display, inflates the view (RecyclerView elements), filling them with data, and inserts them into the RecyclerView. Retrofit is needed to get data from the server. That is, what you need to do:
1) Describe the class (model) of the server response for the retrofit.
2) Make a request to the server.
3) Give the adapter data.
I won’t write code, it’s better to read it yourself:
about Adapter
about Retrofit retrofit
docks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question