Attempt to invoke virtual method On changing Listview item image

不打扰是莪最后的温柔 提交于 2019-12-11 10:26:42

问题


I am not able to change Image on listview item when click on listview button

Logcat error

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

Java code 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);
                 }

        }
    });

Please help me how can solve this issue

Thanks In Advance

来源:https://stackoverflow.com/questions/27009827/attempt-to-invoke-virtual-method-on-changing-listview-item-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!