Picasso IllegalArgumentException Target must not be null

后端 未结 6 816
别跟我提以往
别跟我提以往 2020-11-28 15:49

I\'m trying to set image by using Picasso library on my project.

When I click image of the View,I\'m getting an error on Picasso execution.

Logcat of the ap

相关标签:
6条回答
  • 2020-11-28 16:07

    Check the ID of your imageview object is correct -

    imageView=itemView.findViewById(R.id.imageview1);
    
    0 讨论(0)
  • 2020-11-28 16:09

    Check Id which you set in your layout file.

    android:id="@+id/details_image"
    
    

    Then,

     ImageView image = (ImageView) coverView.findViewById(R.id.details_image);
    
    0 讨论(0)
  • 2020-11-28 16:17

    make sure you inflating the correct xml That was my problem since I copied an already existing adapter and forgot to change that

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(context)
                .inflate(R.layout.list_item_subcategories, parent, false);
    

    Where the layout I should have put was list_item_categories

    0 讨论(0)
  • 2020-11-28 16:17

    Maybe painting.getImageId() is empty or null?

    Or image or getActivity()? :)

    0 讨论(0)
  • 2020-11-28 16:24

    I know this is a little bit old, but one thing that I just spent a bunch of time on is forgetting to run "setContentView" to the layout that the image was on.

    The ImageView is going to be null until the main layout that it lives on is inflated ;)

    0 讨论(0)
  • 2020-11-28 16:29

    image is the target passed to into. It is what's null.

    Ensure that your layout IDs are correct for all configurations and specify @+id/details_image.

    0 讨论(0)
提交回复
热议问题