Trying to Implement Glide inside recyclerView App is crashing. Logcat saying
W/ResourceType: No package identifier when getting name for resource number 0x00000000
V/studio.deploy: Package broadcast exit hook { cmd=3, time=75125210000000, thread=2 }
Fixing application and activity contexts
W/ResourceType: No package identifier when getting name for resource number 0x00000000
E/RecyclerView: No adapter attached; skipping layout
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.tc, PID: 26232
java.lang.IllegalArgumentException: You must pass in a non null View
at com.bumptech.glide.GenericRequestBuilder.into(GenericRequestBuilder.java:685)
at com.bumptech.glide.DrawableRequestBuilder.into(DrawableRequestBuilder.java:457)
at com.example.tc.TCAdapter.onBindViewHolder(TCAdapter.java:44)
at com.example.tc.TCAdapter.onBindViewHolder(TCAdapter.java:22)
My Implementation code is
Glide.with( context ).load( tcImages.get( position ).getFullName() ).into( holder.imageView );
My full Adapter code is
public class TCAdapter extends RecyclerView.Adapter<TCAdapter.MyViewHolder> {
List<TCImages> tcImages;
Context context;
ImageView imageView;
public TCAdapter(List<TCImages> tcImages, Context context){
this.tcImages = tcImages;
this.context = context;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from( context );
View view = inflater.inflate( R.layout.item_tc_recycler, parent, false );
return new MyViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.textView.setText( tcImages.get( position ).getEmail() );
Glide.with( context ).load( tcImages.get( position ).getFullName() ).into( holder.imageView );
// Glide.with( context ).load( "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" ).into( holder.imageView );
// Toast.makeText(context, tcImages.get( position ).getFullName().toString(), Toast.LENGTH_LONG).show();
}
@Override
public int getItemCount() {
return tcImages.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
TextView textView;
ImageView imageView;
public MyViewHolder(@NonNull View itemView) {
super( itemView );
textView = (TextView) itemView.findViewById( R.id.txtItem );
imageView = (ImageView) itemView.findViewById( R.id.imageView );
}
}
}
Tried pasting direct string of image address even then it's crashing
There might be something wrong with your image view, it looks like imageView = (ImageView) itemView.findViewById( R.id.imageView )
might be null, please check if the id is right and if the view is not null
dependent on your Logcat your are load image into NULL ImageView from ViewHolder plaese make sure is Id of ImageView is Correct inside R.layout.item_tc_recycler when bind imageView here
imageView = (ImageView) itemView.findViewById( R.id.imageView );
User contributions licensed under CC BY-SA 3.0