试图调用虚拟方法在改变ListView项图像(Attempt to invoke virtual m

2019-10-21 06:43发布

在列表视图按钮点击,当我不能够改变ListView项图片

logcat的错误

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setBackgroundResource(int)' on a null object reference 

Java代码的onclick

holder.txtnext.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
             try{

                  imageUrls=strimgview.get(pos).split("\\|\\|");
                  i=imageUrls.length;
                  if((i<=1))
                  {
                      i++;
                      ImageView imageView =(ImageView) v.findViewById(R.id.npTupleImage);
                      imageView.setBackgroundResource(R.drawable.logo);
                     // imageLoader.displayImage(imageUrls[i], imageView, options);

                //  Log.d("imageUrlnew ",imageUrls[i]);
                  Log.d("imageUrlnew ",i+"   "+imageUrls.length);

                  }

                 }
                 catch(Exception e)
                 {
                     Log.d("imageUrlnew ",e+"   "+imageUrls.length);
                 }

        }
    });

请帮助我如何才能解决这个问题

提前致谢

文章来源: Attempt to invoke virtual method On changing Listview item image