Recyclerview
item click not always work and sometimes can work but with more more click (don't know how many click).If just click once that can't clicked.
Note few days ago I tried to click once and it's worked, but now when I tried to running again using AS it's not work, even though I not modified that file
My code
public class RecyclerViewAdapterRiwayat extends RecyclerView.Adapter<RecyclerViewAdapterRiwayat.ViewHolder> {
Context context;
private static final String TAG = RecyclerViewAdapterRiwayat.class.getSimpleName();
List<GetDataAdapterRiwayat> getDataAdapter;
ImageLoader imageLoader1;
String FIXURL = "http://192.168.1.101/AndroidFileUpload/";
String url = FIXURL + "uploads/";
String StatusRiwayat;
public RecyclerViewAdapterRiwayat(List<GetDataAdapterRiwayat> getDataAdapter, Context context) {
super();
this.getDataAdapter = getDataAdapter;
this.context = context;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerview_items_riwayat, parent, false);
ViewHolder viewHolder = new ViewHolder(v);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder Viewholder, int position) {
final GetDataAdapterRiwayat getDataAdapter1 = getDataAdapter.get(position);
imageLoader1 = ServerImageParseAdapter.getInstance(context).getImageLoader();
imageLoader1.get(url+getDataAdapter1.getFotoSetelahRiwayat(),
ImageLoader.getImageListener(
Viewholder.networkImageView,//Server Image
R.mipmap.ic_launcher,//Before loading server image the default showing image.
android.R.drawable.ic_dialog_alert //Error image if requested image dose not found on server.
)
);
Viewholder.networkImageView.setImageUrl(url+getDataAdapter1.getFotoSetelahRiwayat(), imageLoader1);
Viewholder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "coba nih5 : "+getDataAdapter1.getNamaJalanRiwayat());
Intent intent = new Intent(v.getContext(), DetailRiwayatActivity.class);
context.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return getDataAdapter.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
public TextView ImageTitleNameView;
public NetworkImageView networkImageView;
public ViewHolder(View itemView) {
super(itemView);
ImageTitleNameView = (TextView) itemView.findViewById(R.id.textView_item_riwayat);
networkImageView = (NetworkImageView) itemView.findViewById(R.id.VollyNetworkImageView2);
}
}
}
If you only have the issue after scrolling / flinging the RecyclerView, it's a known bug in the SupportLibrary
After a user scrolls, they cannot click on an item in a RecyclerView. (AOSP issue 66996774)
Issuetracker ID 66996774 and also 69823266 because it's still not fixed in 27.0.1. Even though Google states it has fixed it.
Most important: the fix here (by Chris Banes, Googler) works perfectly: https://gist.github.com/chrisbanes/8391b5adb9ee42180893300850ed02f2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With