0
I have a RecyclerView
and in each item I would like to check if a fact occurred to show or not a button:
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Posts post = Posts.get(position);
holder.post = post;
//Loading image from url
imageLoader = CustomVolleyRequest.getInstance(context).getImageLoader();
//parte nova que trava (essas 7 linhas):
String lk = post.getLk();
if (lk.equals("1")) { //show button
holder.textViewUnlk.setVisibility(View.VISIBLE);
} else { //hide
holder.textViewLk.setVisibility(View.VISIBLE);
}
holder.textViewName.setText(post.getName());
holder.textViewPublisher.setText(post.getPublisher());
holder.setIsRecyclable(false);
}
The textViewLk
and the textViewUnlk
are in XML as GONE
. What can it be?
Welcome! Please, we ask you to perform a tour by the site and see How to create a Minimum, Complete and Verifiable example. If possible add the errors shown in the Application Log! This helps people help you!
– Thiago Luiz Domacoski
The post.getLk() may be null! But if the error log gets too hard!
– Thiago Luiz Domacoski
You are probably not inflating the views correctly in the viewholder class. It would be better if you post the Recycler view Adapter by compelto.
– Max Fratane