在网格视图中设置bitmap_image和复选框

时间:2017-08-25 03:56:08

标签: android

  

java.lang.NullPointerException:尝试调用虚方法' void android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)' com.example.piker.MultipleShareActivity上的null对象引用$ ImageAdapter1.getView(MultipleShareActivity.java:153)

public View getView(int position, View convertView, ViewGroup parent) {
    Log.e("122","after");
    int width = getScreenWidth();
    LinearLayout linearLayout;
    linearLayout= (LinearLayout) findViewById(R.id.lins);
    ImageView iv=new ImageView(con);
    ImageView iv;
    iv= (ImageView) findViewById(R.id.ims);
    CheckBox cb=new CheckBox(con);
    iv.setImageBitmap(mThumb[0]);// finding error in this line & mthumb is bitmap array//
    linearLayout.addView(iv);
    linearLayout.addView(cb);
    return linearLayout;
}

1 个答案:

答案 0 :(得分:0)

使用此

convertView.findViewById 
在imageview和linearlayout中