E/RecyclerView: No adapter attached; skipping layout - android

I have been reading different answers here on stackoverflow and i tried to implement the solution but I am still getting the same error, I don't know why ! :/
This is my Adapter Class :
public class RecipesAdapter extends RecyclerView.Adapter <RecipesAdapter.RecipeHolder>{
private List<Recipes> recipesList;
private static Recipes recipe;
private static Intent intent;
private Context context;
private View row;
private RecipeHolder holder;
//Conctructor
public RecipesAdapter(List<Recipes> recipesList)
{
this.recipesList=recipesList;
}
//create holder (view)
#Override
public RecipeHolder onCreateViewHolder(ViewGroup parent, int viewType) {
row= LayoutInflater.from(parent.getContext()).inflate(R.layout.recipe_row, parent,false);
//Call constructor : Holder
holder=new RecipeHolder(row);
return holder;
}
#Override
public void onBindViewHolder(RecipeHolder holder, int position) {
recipe= recipesList.get(position);
holder.recipe_title.setText(recipe.getTitle());
Picasso.with(holder.recipe_image.getContext()).load(recipe.getImage_url()).into(holder.recipe_image);
holder.recipe_rank.setText(recipe.getSocial_rank().split("\\.",2)[0]);
holder.recipe_publisher.setText(recipe.getPublisher());
}
#Override
public int getItemCount() {
return recipesList.size();
}
/*To avoid calling methods findViewById for each view, Android has added a concept called ViewHolder
to change 'the values' of each View => concept of Recycling */
public class RecipeHolder extends RecyclerView.ViewHolder
{
private ImageView recipe_image;
private TextView recipe_title,recipe_rank,recipe_publisher;
public RecipeHolder(View itemView) {
super(itemView);
recipe_image=(ImageView) itemView.findViewById(R.id.recipe_img);
recipe_title=(TextView) itemView.findViewById(R.id.recipe_title);
recipe_rank=(TextView) itemView.findViewById(R.id.recipe_rank);
recipe_publisher=(TextView) itemView.findViewById(R.id.recipe_publisher);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
context = v.getContext();
intent = new Intent(context, DetailRecipe.class);
intent.putExtra("url",recipesList.get(getAdapterPosition()).getF2f_url());
intent.putExtra("image",recipesList.get(getAdapterPosition()).getImage_url());
Log.e("log","url is : "+recipe.getF2f_url());
context.startActivity(intent);
}});
}
}
}
onCreate Method
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cookingrecipes);
// Adding Toolbar to Main screen
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Connection_GetData();
}
onResponse Method : when the connection was successful
I used Retrofit library to get data, I called Display_Recipes() to set Adapter
`#Override
public void onResponse(Call<ResultRecipes> call, Response<ResultRecipes> response) {
recipesList = response.body().getRecipes();
//Recycler View
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
/*Performance*/
recyclerView.setItemViewCacheSize(24);
recyclerView.setDrawingCacheEnabled(true);
recyclerView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
recyclerView.setLayoutManager(new GridLayoutManager(CookingRecipes.this, 2));
/*Treatment - Display*/
Display_Recipes();
}`
Display_Recipes() Method
`public void Display_Recipes() {
//Setup Adapter
this.recipeAdapter = new RecipesAdapter(recipesList);
recyclerView.setAdapter(recipeAdapter);
}`
Image Log
Many Thanks,

It's necessary to set LayoutManager on main thread instead of calling inside any callback.
Update your onCreate method as per below :
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cookingrecipes);
// Adding Toolbar to Main screen
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//Shifted your recycler view code here
//Recycler View
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
/*Performance*/
recyclerView.setItemViewCacheSize(24);
recyclerView.setDrawingCacheEnabled(true);
recyclerView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
recyclerView.setLayoutManager(new GridLayoutManager(CookingRecipes.this, 2));
// Only pass context to your adapter
recyclerView.setAdapter(new RecipesAdapter(CookingRecipes.this);
Connection_GetData();
}
And update your onResponse Callback :
#Override
public void onResponse(Call<ResultRecipes> call, Response<ResultRecipes> response) {
recipesList = response.body().getRecipes();
/*Treatment - Display*/
Display_Recipes();
}
Create method to update list in your adapter whenever you need to pass updated list :
public void udpateList(List<Recipes> recipesList){
this.recipesList = recipesList;
notifyDataSetChanged();
}
Now call this method from your Display_Recipes method
public void Display_Recipes() {
//Update Adapter
udpateList(recipesList);
}

Thank you all my friends, I was discovered the error, the code is correct but to avoid this warning, we need to set an empty adapter in onCreate method. After inside the method that you want to get the data, in my case with Retrofit library : Connection_GetData();
1 - create class Adapter like that
public class AdapterFirstUse extends RecyclerView.Adapter {
#Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return null;
}
#Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
}
#Override
public int getItemCount() {
return 0;
}
}
2 - Inside onCreate(Bundle savedInstanceState) method
recyclerView.setAdapter(new AdapterFirstUse());
3 - Inside Connection_GetData()
Setup our Adapter
//Setup Adapter
recipeAdapter = new RecipesAdapter(recipesList);
recyclerView.setAdapter(recipeAdapter);
That's all, Thanks.

The problem might be the adapter is not telling the RecyclerView to update its content.
Add a method in your RecipeAdapter:
public void refresh() {
notifyDataSetChanged();
}
Then call it after binding the adapter to the RecyclerView;
recyclerView.setAdapter(recipeAdapter);
recipeAdapter.update();

Mine was solved by inputting an empty list data first upon initialisation of the adapter, and update data later, example:
initialise adapter in onCreate():
onCreate() {
...
initRecyclerView();
...
}
initRecyclerView() :
public void initRecyclerView() {
//setup recyclerview
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
/*Performance*/
recyclerView.setItemViewCacheSize(24);
recyclerView.setDrawingCacheEnabled(true);
recyclerView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
recyclerView.setLayoutManager(new GridLayoutManager(CookingRecipes.this, 2));
//Setup Adapter
this.recipeAdapter = new RecipesAdapter(new List());//try to set an empty adapter here first
recyclerView.setAdapter(recipeAdapter);
}
then inside onResponse:
#Override
public void onResponse(Call<ResultRecipes> call, Response<ResultRecipes> response) {
//only do data update inside onResponse
recipesList = response.body().getRecipes();
recipeAdapter.recipesList = recipesList;
notifyDataSetChanged();
}

Related

RecyclerView not visible

I have this code in MainActivity
public class MainActivity extends AppCompatActivity implements MainViewInterface{
RecyclerView rvMovies;
private String TAG = "MainActivity";
MoviesAdapter adapter;
MainPresenter mainPresenter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupMVP();
mainPresenter.getMovies();
rvMovies = (RecyclerView)findViewById(R.id.rvMovies);
LinearLayoutManager manager = new LinearLayoutManager(this);
manager.setOrientation(LinearLayoutManager.VERTICAL);
rvMovies.setLayoutManager(manager);
//rvMovies.setHasFixedSize(true);
}
private void setupMVP() {
mainPresenter = new MainPresenter(this);
}
#Override
public void showToast(String s) {
Toast.makeText(MainActivity.this,s,Toast.LENGTH_LONG).show();
}
#Override
public void displayMovies(MovieResponse moviesResponse) {
if(moviesResponse!=null) {
Log.d(TAG,moviesResponse.getResults().get(1).getTitle());
adapter = new MoviesAdapter(moviesResponse.getResults(), MainActivity.this);
rvMovies.setAdapter(adapter);
adapter.notifyDataSetChanged();
}else{
Log.d(TAG,"Movies response null");
}
}
#Override
public void displayError(String s) {
showToast(s);
}
}
But I get this
E/RecyclerView: No adapter attached; skipping layout
I know other people asked the same question. I tried their solutions but didn't work. What am I missing?
This is my adapter code.
public class MoviesAdapter extends RecyclerView.Adapter<MoviesAdapter.MoviesHolder> {
List<Result> movieList;
Context context;
public MoviesAdapter(List<Result> movieList, Context context){
this.movieList = movieList;
this.context = context;
}
#Override
public MoviesHolder onCreateViewHolder( ViewGroup parent, int viewType) {
View v = LayoutInflater.from(context).inflate(R.layout.row_movies,parent,false);
MoviesHolder mh = new MoviesHolder(v);
return mh;
}
#Override
public void onBindViewHolder( MoviesHolder holder, int position) {
holder.tvTitle.setText(movieList.get(position).getTitle());
holder.tvOverview.setText(movieList.get(position).getOverview());
holder.tvReleaseDate.setText(movieList.get(position).getReleaseDate());
Glide.with(context).load("https://image.tmdb.org/t/p/w500/"+movieList.get(position).getPosterPath()).into(holder.ivMovie);
}
#Override
public int getItemCount() {
return movieList.size();
}
public class MoviesHolder extends RecyclerView.ViewHolder {
TextView tvTitle,tvOverview,tvReleaseDate;
ImageView ivMovie;
public MoviesHolder(View itemView) {
super(itemView);
tvTitle = (TextView) itemView.findViewById(R.id.tvTitle);
tvOverview = (TextView) itemView.findViewById(R.id.tvOverView);
tvReleaseDate = (TextView) itemView.findViewById(R.id.tvReleaseDate);
ivMovie = (ImageView) itemView.findViewById(R.id.ivMovie);
}
}
Thanks,
Theo.
SOLVED
In my activivity_main.xml I had both height and with equal to 0dp!!! I honestly don't know how and who put those values in!! That's why the recycler view was not visible!!!
I think you should call rvMovies.setAdapter(new MoviesAdapter(new ArrayList<>())) on your RecyclerView during onCreate - there is nothing bad about setting an empty (from items perspective) adapter on RecyclerView, it will simply show an empty list. Then once you have your data ready (downloaded/loaded from any source you are loading from) you will simply call something like adapter.setItems(newItemsList) and adapter.notifyDataSetChanged().
Also one more note: you should not store Context in class member fields as leaks might occur (I am pretty sure your Android Studio must complain about that as well in a form of a Lint Warning check). You actually don't even need that Context instance passing to your adapter as you can simply retrieve a Context instance from parent View in onCreateViewHolder - rewrite it like this:
#Override
public MoviesHolder onCreateViewHolder( ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_movies,parent,false);
MoviesHolder mh = new MoviesHolder(v);
return mh;
}
These 2 lines:
setupMVP();
mainPresenter.getMovies();
must be written after:
rvMovies = (RecyclerView)findViewById(R.id.rvMovies);
you need to set adapter after you set the views.
rvMovies = (RecyclerView)findViewById(R.id.rvMovies);
LinearLayoutManager manager = new LinearLayoutManager(this);
manager.setOrientation(LinearLayoutManager.VERTICAL);
rvMovies.setLayoutManager(manager);
//rvMovies.setHasFixedSize(true);
//call after setting the view
mainPresenter.getMovies();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupMVP();
rvMovies = (RecyclerView)findViewById(R.id.rvMovies);
LinearLayoutManager manager = new LinearLayoutManager(this);
manager.setOrientation(LinearLayoutManager.VERTICAL);
rvMovies.setLayoutManager(manager);
rvMovies.setVisibility(View.VISIBLE);
mainPresenter.getMovies(); <== put this line in last
}

Getting Android RecyclerView to update view inside React Native component

I am making a mobile application using React Native and included list components didn't have high enough performance for it so I started using Android's RecyclerView as the list component. There is a problem though with it. The RecyclerView doesn't update its contents views until I scroll or change RecyclerView's size. What could cause this problem and how I can fix it? I have tried notifyDatasetChanged, notifyItemChanged, forceLayout, invalidate, postInvalidate and many different variations with each.
Try this one this.setIsRecyclable(true);
It will referesh your views
public class MainActivity extends AppCompatActivity {
private RecyclerView mRecyclerView;
private ArrayList<String> mSingleItemLists = new ArrayList<>();
private SingleListItemAdapter mSingleListItemAdapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_single_item);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(linearLayoutManager);
setDummyData();
}
private void setDummyData() {
for (int i = 0; i <= 30; i++)
mSingleItemLists.add("item" + i);
}
#Override
protected void onResume() {
super.onResume();
mSingleListItemAdapter = new SingleListItemAdapter(mSingleItemLists);
mRecyclerView.setAdapter(mSingleListItemAdapter);
}
class SingleListItemAdapter extends RecyclerView.Adapter<SingleListItemAdapter.SingleListItemHolder> {
private ArrayList<String> mSingleItemLists;
private SingleListItemAdapter(ArrayList<String> singleItemLists) {
mSingleItemLists = singleItemLists;
//You can do notifydatasetchange if u r having any saved value
}
#Override
public SingleListItemAdapter.SingleListItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View inflatedView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_recyclerview, parent, false);
return new SingleListItemHolder(inflatedView);
}
#Override
public void onBindViewHolder(SingleListItemAdapter.SingleListItemHolder holder, int position) {
holder.mItemDate.setText(mSingleItemLists.get(position));
}
#Override
public int getItemCount() {
return mSingleItemLists.size();
}
class SingleListItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private TextView mItemDate;
SingleListItemHolder(View v) {
super(v);
mItemDate = (TextView) v.findViewById(R.id.textview_recycler_list_item);
v.setOnClickListener(this);
this.setIsRecyclable(true); // This will help u
}
#Override
public void onClick(View v) {
//do your stuff
notifyDataSetChanged();
}
}
}
}

RecyclerView not populating with data

I am trying to load recyclerview with data from SQLite database contents. But it is not working
This is what i have done
Activity class
public class ViewMembership extends AppCompatActivity {
private RecyclerView recyclerView;
private membership_view_recycler_adapter m;
private DBHelper dbHelper;
public List<membership_recycler_model> membershipList=new ArrayList<>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_membership);
dbHelper=new DBHelper(this);
////////////////////////////////////////////////////////////////////////////
recyclerView=(RecyclerView) findViewById(R.id.View_Membership_Recycler);
m=new membership_view_recycler_adapter(membershipList);
RecyclerView.LayoutManager layoutManager=new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
recyclerView.setAdapter(m);
prepare_membership();
//////////////////////////////////////////////////////////////////////////
}
public void prepare_membership()
{
System.out.println("#######################Prepare_membership called");
membershipList=dbHelper.membership_for_recycler_view();
m.notifyDataSetChanged();
}}
Adapter class
public class membership_view_recycler_adapter extends RecyclerView.Adapter<membership_view_recycler_adapter.MyViewHolder> {
public class MyViewHolder extends RecyclerView.ViewHolder {
public TextView name,region;
public MyViewHolder(View itemView) {
super(itemView);
name=(TextView) itemView.findViewById(R.id.membership_name_textview);
region=(TextView) itemView.findViewById(R.id.membership_region_textview);
}
}
public membership_view_recycler_adapter(List<membership_recycler_model> membership_list) {
this.membership_list = membership_list;
}
private List<membership_recycler_model> membership_list;
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.membership_view_row,parent,false);
return new MyViewHolder(view);
}
#Override
public void onBindViewHolder(MyViewHolder holder, int position) {
membership_recycler_model membership=membership_list.get(position);
holder.name.setText(membership.getMembership_name());
holder.region.setText(membership.getRegion());
}
#Override
public int getItemCount() {
return membership_list.size();
}}
I've got no compilation errors, application is not throwing any exceptions. dbHelper.membership_for_recycler_view() is returning appropriate values. I am kinda new in Android. I did this with the help of a tutorial. What have I done wrong?
I think the problem here is you are calling prepare_membership()
function later and passing data to your adapter before with an empty list. Try to make following changes :
Add a new method in your adapter -
public void refreshData(List<membership_recycler_model> membership_list){
this.membership_list = membership_list;
notifyDataSetChanged();
}
Inside your prepare_membership() function call this method after fetching the list from db i.e m.refreshData(membershipList)
`

updating the master/detail list view in android on data change

I have implemented the android master/detail flow template in android. I have changed it so that it loads the data from database on first load. The list populates fine.
I have a refresh button which calls an asyncTask with a callback, which effectively updates the data using http and updates the database. I now need to update the data in the list. I have tried several approaches to update the recyclerView but it just wont update. Any ideas.
public void refreshWeatherCharts() {
WeatherChartFetchData callbackservice = new WeatherChartFetchData(this) {
#Override
public void receiveData(boolean success) {
if (success)
WeatherChartListBuilder.loadData();
// RecyclerView.Adapter adapter = ((RecyclerView) recyclerView).getAdapter();
RecyclerView rc = (RecyclerView) recyclerView;
rc.invalidate();
}
};
callbackservice.execute(null, null, null);
}
private void setupRecyclerView(#NonNull RecyclerView recyclerView) {
recyclerView.setAdapter(new SimpleItemRecyclerViewAdapter(WeatherChartListBuilder.ITEMS));
}
/////////
public class SimpleItemRecyclerViewAdapter
extends RecyclerView.Adapter<SimpleItemRecyclerViewAdapter.ViewHolder> {
private final List<WeatherChart> mValues;
public SimpleItemRecyclerViewAdapter(List<WeatherChart> items) {
mValues = items;
}
public void updateData(ArrayList<WeatherChart> viewModels) {
mValues.clear();
mValues.addAll(viewModels);
notifyDataSetChanged();
}
public void addItem(int position, WeatherChart viewModel) {
mValues.add(position, viewModel);
notifyItemInserted(position);
}
public void removeItem(int position) {
mValues.remove(position);
notifyItemRemoved(position);
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.weatherchart_list_content, parent, false);
return new ViewHolder(view);
}
Managed to sort it. I refactored the recyclerView to the following:
recyclerView = (RecyclerView) findViewById(R.id.weatherchart_list);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new SimpleItemRecyclerViewAdapter(ITEMS);
// new SimpleItemRecyclerViewAdapter(ITEMS);
//SimpleItemRecyclerViewAdapter.ViewHolde
recyclerView.setAdapter(mAdapter);
You don't need to create a new adapter each time some item's value changes in your data set or if you added new items to your data set, or removed items, or even if the whole list has changed. Just update the data set in your adapter which in your case is a List of WeatherCharts.
public void refreshWeatherCharts() {
WeatherChartFetchData callbackservice = new WeatherChartFetchData(this) {
#Override
public void receiveData(boolean success) {
if (success) {
WeatherChartListBuilder.loadData();
RecyclerView.Adapter adapter = ((RecyclerView) recyclerView).getAdapter();
((SimpleItemRecyclerViewAdapter) adapter).updateData(WeatherChartListBuilder.ITEMS);
}
}
};
callbackservice.execute(null, null, null);
}
viewAdapter = recyclerView.getAdapter();
viewAdapter.notifyDataSetChanged();

Setting Adapter in recyclerview

I am trying to use recyclerview and setting up adapter but I am getting error :-
No adapter attached; skipping layout
So please help me how to solve this problem
public class FragmentTwo extends Fragment {
private AppAdapter mAppAdapter;
private ArrayList<Model> mModel;
#Bind(R.id.recycler_view)
RecyclerView recyclerView;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_two, container, false);
ButterKnife.bind(this, v);
recyclerView.setHasFixedSize(true);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(mAppAdapter);
parseData();
return v;
}
private void parseData() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("url")
.addConverterFactory(GsonConverterFactory.create())
.build();
ReqInterface reqInterface = retrofit.create(ReqInterface.class);
Call<Model> call = reqInterface.getAdvanceData("france");
call.enqueue(new Callback<Model>() {
#Override
public void onResponse(Call<Model> call, Response<Model> response) {
Model model = response.body();
mModel = new ArrayList<Model>(Arrays.asList(model));
mAppAdapter = new AppAdapter(mModel);
recyclerView.setAdapter(mAppAdapter);
mAppAdapter.notifyDataSetChanged();
}
#Override
public void onFailure(Call<Model> call, Throwable t) {
}
});
}
}
Here is my Recyclerview Adapter class:-
public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> {
private ArrayList<Model> mModel;
TextView highTemp;
public AppAdapter(ArrayList<Model> model) {
mModel = model;
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView highTemp;
public ViewHolder(View view) {
super(view);
highTemp = (TextView) view.findViewById(R.id.card_view_tv_hightemp);
}
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View view = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.fragment_two, viewGroup, false);
return new ViewHolder(view);
}
#Override
public void onBindViewHolder(ViewHolder viewHolder, int i) {
viewHolder.highTemp.setText(String.valueOf(mModel.getName);
}
#Override
public int getItemCount() {
return mModel.size();
}
}
Thanks in advance
You never initialize the adapter mAppAdapter so it's null at runtime. You're missing something like mAppAdapter = new AppAdapter(yourdata);
before the call to setAdapter.
Your adapter mAppAdapter is never initialised i.e. it is null.
Therefore recyclerView.setAdapter(mAppAdapter); is the same as recyclerView.setAdapter(null); so you aren't actually ever setting an adapter!
Remember to initialise your fields:
mAppAdapter = new AppAdapter(mModel); // or whatever constructor you want
recyclerView.setAdapter(mAppAdapter);
Change
recyclerView.setAdapter(mAppAdapter);
to
recyclerView.setAdapter(new AppAdapter(model));
You never create your mAppAdapter.
To solve this, create a new instance of your adapter and pass that in the parameters of .setAdapter.
In other words, you should use .setAdapter(new AppAdapter(...)) where ... is replaced with the parameters that you have created in AppAdapter.
I usually do the retrofit call in an asynctask, then when you get the response from the server, you create a new adapter and set it to the recyclerview.
Anyway, try removing the .setAdapter line from the onCreate() method and just leave it as you have it.
It works and it doesn't crash, the reason it crashes it's because the adapter is null (it has no elements).
I hope it helps!

Categories

Resources