I was trying to write own adapter class in Android Studio which looks something like this:
public class Adapter extends RecyclerView.Adapter<Adapter.MyViewHolder>{
private List<Article> articles;
private Context context;
private OnItemClickListener onItemClickListener;
public Adapter(List<Article> articles, Context context) {
this.articles = articles;
this.context = context;
}
public void setOnItemClickListener(OnItemClickListener onItemClickListener){
this.onItemClickListener = onItemClickListener;
}
public interface OnItemClickListener {
void onItemClick(View view, int position);
}
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView title, desc, author, published_ad, source, time;
ImageView imageView;
ProgressBar progressBar;
OnItemClickListener onItemClickListener;
public MyViewHolder(View itemView, OnItemClickListener onItemClickListener) {
super(itemView);
itemView.setOnClickListener(this);
title = itemView.findViewById(R.id.title);
desc = itemView.findViewById(R.id.decs);
author = itemView.findViewById(R.id.author);
published_ad = itemView.findViewById(R.id.publishedAt);
source = itemView.findViewById(R.id.source);
time = itemView.findViewById(R.id.time);
imageView = itemView.findViewById(R.id.img);
progressBar = itemView.findViewById(R.id.progress_load_photo);
this.onItemClickListener = onItemClickListener;
}
#Override
public void onClick(View v) {
onItemClickListener.onItemClick(v, getAdapterPosition());
}
}
}
And the class in which I use my Adapter looks like this:
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.news, container, false);
recyclerView = view.findViewById(R.id.recyclerView);
layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setNestedScrollingEnabled(false);
adapter = new Adapter(articles, getActivity().getApplicationContext());
recyclerView.setAdapter(adapter);
LoadJson();
return view;
}
I am getting an error about null pointer exception: "Attempt to invoke interface method 'void com.example.app2.Adapter$OnItemClickListener.onItemClick(android.view.View, int)' on a null object reference"
Your field Adapter.onItemClickListener is null until you set it up (what you never do in your actual code)
So you should test if there is a listener before trying to notify it.
#Override
public void onClick(View v) {
if (onItemClickListener != null)
onItemClickListener.onItemClick(v, getAdapterPosition());
}
And I guess you would use it in your onCreateView method :)
adapter = new Adapter(articles, getActivity().getApplicationContext());
adapter.setOnItemClickListener(() -> { System.out.println("Click !") });
recyclerView.setAdapter(adapter);
Related
I am a beginner at android development. I tried to display data on Recycle View using MVVM. When I opened the fragment the first time it is empty, the second time it showed data. Adapter not called the first time. How to fix this.
Fragment class
public class fragmentEmployee extends Fragment {
private FragmentEmployeeBinding binding;
private ViewGroup viewGroup;
private View view;
private RecyclerView mRecycleView;
private UserAdapter mAdapter;
private EmployeeRegisterViewModel viewModel;
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_employee, viewGroup, false);
view = binding.getRoot();
return view;
}
#Override
public void onViewCreated(#NonNull View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Toast.makeText(getContext(), "onViewCreated", Toast.LENGTH_SHORT).show();
mRecycleView = binding.recyleViewEmployee;
viewModel = new ViewModelProvider(this).get(EmployeeRegisterViewModel.class);
viewModel.init();
initRecycleView();
viewModel.getEmployee().observe(getViewLifecycleOwner(), new Observer<List<employeeModel>>() {
#Override
public void onChanged(List<employeeModel> employeeModels) {
mAdapter.notifyDataSetChanged();
}
});
}
private void initRecycleView() {
mAdapter = new UserAdapter(getContext(), viewModel.getEmployee().getValue());
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
mRecycleView.setLayoutManager(layoutManager);
mRecycleView.setAdapter(mAdapter);
}
}
UserAdapter class
public class UserAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
public List<employeeModel> employeeModelList= new ArrayList<>();
public Context context1;
public UserAdapter(Context context,List<employeeModel> employeeModels){
employeeModelList = employeeModels;
context1 = context;
}
#NonNull
#Override
public RecyclerView.ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_listitem,parent,false);
ViewHolder viewHolder=new ViewHolder(view);
return viewHolder;
}
#Override
public void onBindViewHolder(#NonNull RecyclerView.ViewHolder holder, int position) {
(ViewHolder)holder).username.setText(employeeModelList.get(position).getName());
}
#Override
public int getItemCount() {
return employeeModelList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
TextView username;
public ViewHolder(#NonNull View itemView) {
super(itemView);
username=itemView.findViewById(R.id.userText);
}
}
}
Try reordering like this.
Remove
mAdapter = new UserAdapter(getContext(), viewModel.getEmployee().getValue());
from initRecycleView
mAdapter = new UserAdapter(getContext(), viewModel.getEmployee().getValue());
viewModel.getEmployee().observe(getViewLifecycleOwner(), new Observer<List<employeeModel>>() {
#Override
public void onChanged(List<employeeModel> employeeModels) {
mAdapter.notifyDataSetChanged();
}
});
initRecycleView();
mAdapter.notifyDataSetChanged();
Above method will work if the list declared inside adapter has any change. So, calling above method without changing adapter's list is useless.
Add a method to UserAdapter class to update list data. Like:
public void updateData(List<employeeModel> updatedList){
employeeModelList.clear();
employeeModelList.addAll(updatedList);
notifyDataSetChanged();
}
And call this method inside observer. Like:
viewModel.getEmployee().observe(getViewLifecycleOwner(), new
Observer<List<employeeModel>>() {
#Override
public void onChanged(List<employeeModel> employeeModels) {
mAdapter.updateData(employeeModels);
}
});
where are you get your network data?
If your get in here -> viewModel.init();
I think it just timing problem.
Just change code sequence
initRecycleView();
viewModel.getEmployee().observe(getViewLifecycleOwner(), new Observer<List<employeeModel>>() {
#Override
public void onChanged(List<employeeModel> employeeModels) {
mAdapter.notifyDataSetChanged();
}
});
viewModel.init();
I am trying to send the context from my java class to my adapter of a RecyclerView, so I can click on the elements and be redirected to an intent. Apparently, the context isn't right. I've commented its line and the app works, but as soon as i try to prove it, it starts crashing again.
I assume its a context thing, but it would be pretty helpful if there's another way to set a click method to my elements.
The exception it throw its a null pointer exception:
java.lang.RuntimeException: Unable to start activity:
java.lang.NullPointerException: Attempt to invoke virtual method 'void
android.widget.Button.setOnClickListener(android.view.View$OnClickListener)'
on a null object reference
Here is the adapter code:
public class SubsidioAdapter extends RecyclerView.Adapter<SubsidioAdapter.SubsidioViewHolder> {
private Context context;
private List<Producto> productoList;
private LayoutInflater inflater;
public SubsidioAdapter(Context context, List<Producto> productoList) {
this.context = context;
this.productoList = productoList;
this.inflater = LayoutInflater.from(context);
}
#Override
public SubsidioViewHolder onCreateViewHolder(#NonNull ViewGroup viewGroup, int i) {
View view = this.inflater.inflate(R.layout.producto_item, null);
return new SubsidioViewHolder(view);
}
#Override
public void onBindViewHolder(SubsidioViewHolder subsidioViewHolder, int position) {
subsidioViewHolder.imageView.setImageResource(this.productoList.get(position).getFoto());
subsidioViewHolder.textView1.setText(this.productoList.get(position).getNombre());
subsidioViewHolder.textView2.setText(this.productoList.get(position).getDescripcion());
subsidioViewHolder.textView3.setText(this.productoList.get(position).getPrecio());
subsidioViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
context.startActivity(new
Intent(context, ModificarProductoActivity.class));
}
});
}
#Override
public int getItemCount() {
return this.productoList.size();
}
public class SubsidioViewHolder extends RecyclerView.ViewHolder {
ImageView imageView;
TextView textView1;
TextView textView2;
TextView textView3;
public SubsidioViewHolder(View itemView) {
super(itemView);
this.imageView = itemView.findViewById(R.id.fotoSub);
this.textView1 = itemView.findViewById(R.id.descSub);
this.textView2 = itemView.findViewById(R.id.nombreSub);
this.textView3 = itemView.findViewById(R.id.precioSub);
}
}
}
set an id to root element of adapter item layout, then find that view by id and use it instead of itemView ,
instead of :
subsidioViewHolder.itemView.setOnClickListener(new View.OnClickListener(){
public void onClick(View view) {
...
}
});
use:
subsidioViewHolder.rootLayout.setOnClickListener(new View.OnClickListener(){
public void onClick(View view) {
...
}
});
. and remember you can get context in recyclerView adapter inside onCreateViewHolder() without using constructor like this:
#Override
public SubsidioViewHolder onCreateViewHolder(#NonNull ViewGroup viewGroup, int i) {
context=viewGroup.getContext();
View view = this.inflater.inflate(R.layout.producto_item, null);
return new SubsidioViewHolder(view);
}
although it seems like that your problem is with
I am trying to make dynamical list using RecyclerView and CardView using tutorial from this site and I am getting this error:
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
at kawi15.myapplication.CustomAdapter.getItemCount(CustomAdapter.java:66)
I run debugger to check that I have results from tmbd API and this is what I received:
http://prntscr.com/vdjj1h
This is my Fragment class activity when I want to create that list:
public class FragmentOne extends Fragment {
private static RecyclerView.Adapter adapter;
private RecyclerView.LayoutManager layoutManager;
private static RecyclerView recyclerView;
private static List<MovieDb> data;
static View.OnClickListener myOnClickListener;
public static FragmentOne newInstance() {
FragmentOne fragment = new FragmentOne();
return fragment;
}
public class MovieTask extends AsyncTask<Void, Void, List<MovieDb>> {
#Override
protected List<MovieDb> doInBackground(Void... voids) {
MovieResultsPage movies = new TmdbApi("f753872c7aa5c000e0f46a4ea6fc49b2").getMovies().getUpcoming("en-US", 1, "US");
List<MovieDb> listMovies = movies.getResults();
return listMovies;
}
#Override
protected void onPostExecute(List<MovieDb> movieDb) {
data = movieDb;
}
}
#Override
public void onCreate(Bundle savedInstanceState) {
MovieTask mt = new MovieTask();
mt.execute();
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View returnView = inflater.inflate(R.layout.fragment_one, container, false);
recyclerView = (RecyclerView) returnView.findViewById(R.id.my_recycler_view);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getContext()); // ???
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
adapter = new CustomAdapter(data);
recyclerView.setAdapter(adapter);
return returnView;
}
}
and my Adapter class:
public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.MyViewHolder> {
private List<MovieDb> dataSet;
public static class MyViewHolder extends RecyclerView.ViewHolder {
TextView textViewName;
TextView textViewVersion;
ImageView imageViewIcon;
public MyViewHolder(View itemView) {
super(itemView);
this.textViewName = (TextView) itemView.findViewById(R.id.text1);
this.textViewVersion = (TextView) itemView.findViewById(R.id.text2);
this.imageViewIcon = (ImageView) itemView.findViewById(R.id.imageView);
}
}
public CustomAdapter(List<MovieDb> data) {
this.dataSet = data;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.cards_layout, parent, false);
//view.setOnClickListener(MainActivity.myOnClickListener);
MyViewHolder myViewHolder = new MyViewHolder(view);
return myViewHolder;
}
#Override
public void onBindViewHolder(final MyViewHolder holder, final int listPosition) {
TextView textViewName = holder.textViewName;
TextView textViewVersion = holder.textViewVersion;
ImageView imageView = holder.imageViewIcon;
Glide.with(imageView).load("http://image.tmdb.org/t/p/w500" + dataSet.get(listPosition).getPosterPath()).into(imageView);
textViewName.setText(dataSet.get(listPosition).getOriginalTitle());
textViewVersion.setText(dataSet.get(listPosition).getReleaseDate());
//imageView.setImageResource(dataSet.get(listPosition).);
}
#Override
public int getItemCount() {
return dataSet.size();
}
}
I stucked with my code with this and I dont have idea where is mistake.
Initially dataSet is null. So using dataSet.size() is throwing NullPointerException.
Change getItemCount method in the following way.
#Override
public int getItemCount() {
if(dataSet == null){
return 0;
}
return dataSet.size();
}
This is removing error but its still doesnt work because data is null making dataSet null too. I dont know why data is null, I need help with this.
Reason for that could be, you are creating CustomAdapter object in onCreateView method, which is kind of called before you AsyncTask has finished. So, when onCreateView is being called, data is null.
To fix it, You can add a setter method in your CustomAdapter, which will allow you to update dataSet, even after the adapter object is created. Then you will have to update the dataSet in your onPostExecute method & after that use notifyDataSetChanged on the adapter, to reflect the changes.
At the start dataSet will be null until you assign it a value, and then feed it back with data, so change getItemCount() to below to return 0 data when it's null
#Override
public int getItemCount() {
return dataSet == null ? 0 : dataSet.size();
}
Ok, there is no error and application is launching but still I dont have list and this is my problem
You need to update the changes to your adapter with notifyDataSetChanged()
#Override
protected void onPostExecute(List<MovieDb> movieDb) {
data = movieDb;
adapter.notifyDataSetChanged();
}
Now two possible things, either TmdbApi("...").getMovies() doesn't really return data, in this case you need to debug it and check if it returns data or not.
The other thing, move the code of the AsyncTask execution after creating the RecyclerView instance in onCreateView and Initialize the adapter in onPostExecute();
Here are after the changes:
public class MovieTask extends AsyncTask<Void, Void, List<MovieDb>> {
#Override
protected List<MovieDb> doInBackground(Void... voids) {
MovieResultsPage movies = new TmdbApi("f753872c7aa5c000e0f46a4ea6fc49b2").getMovies().getUpcoming("en-US", 1, "US");
List<MovieDb> listMovies = movies.getResults();
return listMovies;
}
#Override
protected void onPostExecute(List<MovieDb> movieDb) {
data = movieDb;
adapter = new CustomAdapter(data);
recyclerView.setAdapter(adapter);
}
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View returnView = inflater.inflate(R.layout.fragment_one, container, false);
recyclerView = (RecyclerView) returnView.findViewById(R.id.my_recycler_view);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getContext()); // ???
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
MovieTask mt = new MovieTask();
mt.execute();
return returnView;
}
E/RecyclerView: No adapter attached; skipping layout
I've seen almost a similar question like this on the site but they are kind of different problems , because in my case nothing works. I tried that solution but NO LUCK
I've clearly attached the adapter why this error is shown and in my case nothing happens , no fragment is shown
public class MessageFragment extends Fragment {
private RecyclerView recyclerViewMessages;
private RecyclerView.Adapter adapter;
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState)
{ return inflater.inflate(R.layout.fragment_messages, container, false);
}
#Override
public void onViewCreated(View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getActivity().setTitle("Messages");
recyclerViewMessages = (RecyclerView) view.findViewById(R.id.recyclerViewMessages);
recyclerViewMessages.setHasFixedSize(true);
recyclerViewMessages.setLayoutManager(new LinearLayoutManager(getActivity()));
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(APIUrl.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
APIService service = retrofit.create(APIService.class);
Call<Messages> call = service.getMessages(SharedPrefManager.getInstance(getActivity()).getUser().getId());
call.enqueue(new Callback<Messages>() {
#Override
public void onResponse(Call<Messages> call, Response<Messages> response) {
adapter = new MessageAdapter(response.body().getMessages(), getActivity());
recyclerViewMessages.setAdapter(adapter);
Log.d("Tag","onResponse" );
}
#Override
public void onFailure(Call<Messages> call, Throwable t) {
Toast.makeText(getActivity(), t.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
}
the error is (as you can see i get the error onResponse so there shouldn't be a problem with API :
E/RecyclerView: No adapter attached; skipping layout
D/Tag: onResponse
Just in case if you need to see the adapter class:
public class MessageAdapter extends
RecyclerView.Adapter<MessageAdapter.ViewHolder> {
private List<Message> messages;
private Context mCtx;
public MessageAdapter(List<Message> messages, Context mCtx) {
this.messages = messages;
this.mCtx = mCtx;
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_messages, parent, false);
return new ViewHolder(v);
}
#Override
public void onBindViewHolder(MessageAdapter.ViewHolder holder, int position) {
final Message message = messages.get(position);
holder.textViewName.setText(message.getFrom());
holder.textViewTitle.setText(message.getTitle());
holder.textViewMessage.setText(message.getMessage());
holder.textViewTime.setText(message.getSent());
}
#Override
public int getItemCount() {
return messages.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView textViewName;
public TextView textViewTitle;
public TextView textViewMessage;
public TextView textViewTime;
public ViewHolder(View itemView) {
super(itemView);
textViewName = (TextView) itemView.findViewById(R.id.textViewName);
textViewTitle = (TextView) itemView.findViewById(R.id.textViewTitle);
textViewMessage = (TextView) itemView.findViewById(R.id.textViewMessage);
textViewTime = (TextView) itemView.findViewById(R.id.textViewTime);
}
}
}
Is it possible that the problem could be caused because of something else (another part of the program?
I'm trying to add a recyclerview to a fragment, but somehow there happens to be an error in the adapter.
I think it is the way in which I bind it, and I can't figure out the solution to it. Can anybody help me solve the issue?
here's my adapter:
public class MyLeaguesListAdapter extends
RecyclerView.Adapter<MyLeaguesListAdapter.MyViewHolder>{
List<MyContest> listItems;
Context context;
public interface OnItemClickListener {
void onItemClick(View v,int pos);
}
public MyLeaguesListAdapter(List<MyContest> listItems,Context context){
this.listItems = listItems;
this.context = context;
}
#NonNull
#Override
public MyViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View v;
v = LayoutInflater.from(context).inflate(R.layout.my_contest_item,parent,false);
MyViewHolder myViewHolder = new MyViewHolder(v);
return myViewHolder;
}
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
public TextView leagueName,playerName,prizePool,playerRank,playerPoints,entryFee,spots;
OnItemClickListener onItemCheckListener;
public MyViewHolder(View itemView) {
super(itemView);
leagueName = (TextView) itemView.findViewById(R.id.mc_contest_name);
playerName = (TextView) itemView.findViewById(R.id.mc_player_name);
prizePool = (TextView) itemView.findViewById(R.id.mc_prize_pool);
playerRank = (TextView) itemView.findViewById(R.id.mc_player_rank);
playerPoints = (TextView) itemView.findViewById(R.id.mc_player_points);
entryFee = (TextView) itemView.findViewById(R.id.mc_entry_fee);
spots = (TextView) itemView.findViewById(R.id.mc_spots);
itemView.setOnClickListener(this);
}
public void setItemClickListener(OnItemClickListener ic){
this.onItemCheckListener = ic;
}
#Override
public void onClick(View view) {
this.onItemCheckListener.onItemClick(view,getAdapterPosition());
}
}
#Override
public int getItemCount() {
return listItems.size();
}
#Override
public void onBindViewHolder(#NonNull MyViewHolder holder, int position) {
MyContest listItem = listItems.get(position);
holder.leagueName.setText(listItem.getLeaguename());
holder.prizePool.setText(listItem.getPrizepool());
holder.playerPoints.setText(listItem.getScore());
holder.playerRank.setText(listItem.getRank());
holder.playerName.setText(listItem.getUsername());
holder.spots.setText(listItem.getSpots());
holder.entryFee.setText(listItem.getFee());
holder.setItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(View v, int pos) {
}
});
}
}
this is my fragment:
public class MyLeagues extends Fragment {
SharedPreferences sharedPreferences,ui;
int score,userid,i=0;
String username,lname,inviteCode;
List<MyContest> list_item;
MyLeaguesListAdapter adapter;
ProgressBar progressBar;
Sprite fadingCircle;
RecyclerView recyclerView;
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_my_leagues,null);
ui = this.getActivity().getSharedPreferences("User",Context.MODE_PRIVATE);
userid = ui.getInt("userid",-1);
progressBar = (ProgressBar) view.findViewById(R.id.mcspin_kit);
fadingCircle = new FadingCircle();
progressBar.setIndeterminateDrawable(fadingCircle);
Log.d("eede", "onCreateView: "+inviteCode);
recyclerView = (RecyclerView) view.findViewById(R.id.mc_recycler);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), LinearLayoutManager.VERTICAL));
list_item = new ArrayList<>();
getMYContests();
return view;
}
public void getMYContests(){
Call<MyContestResponse> call = RetrofitClient
.getInstance()
.getApi()
.getMycontests(userid);
call.enqueue(new Callback<MyContestResponse>() {
#Override
public void onResponse(Call<MyContestResponse> call, Response<MyContestResponse> response) {
list_item=response.body().getData();
adapter = new MyLeaguesListAdapter(list_item,getContext());
progressBar.setVisibility(View.INVISIBLE);
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
#Override
public void onFailure(Call<MyContestResponse> call, Throwable t) {
Log.d("bruv", "onFailure: "+t);
}
});
}
}
error:
07-03 09:36:20.980 30095-30095/? E/AndroidRuntime: FATAL EXCEPTION:
main
Process: com.example.android.khelo, PID: 30095
android.content.res.Resources$NotFoundException: String resource ID #0xffffffff
at android.content.res.Resources.getText(Resources.java:363)
at android.widget.TextView.setText(TextView.java:6485)
at com.example.android.khelo.MyLeaguesListAdapter.onBindViewHolder(MyLeaguesListAdapter.java:75)
at com.example.android.khelo.MyLeaguesListAdapter.onBindViewHolder(MyLeaguesListAdapter.java:20)
from what I've read, the issue is with the way I bind the recylerview but I've not got a clear idea about where the issue actually lies.
It is possible that one or many of your listItem attributes return an integer like getScore and getFee. So let's look at the implementation of TextView.setText(int)
public final void setText(int resid) {
...
}
As you can see, it only accepts the int as a resource id like R.string.something.
So what you can do here is to make your int become string when setText like
holder.playerPoints.setText(listItem.getScore().toString());