对话框中的空指针异常

时间:2011-12-02 02:52:56

标签: android android-layout nullpointerexception

我在Dialog上遇到NullPointerException。这是我的代码:

@Override
public boolean onDoubleTap(MotionEvent e) {
    Toast.makeText(getApplication(), "test lang ito! ", Toast.LENGTH_SHORT).show();
    Dialog d = new Dialog(getApplicationContext());
    d.setContentView(R.layout.popup_image);
    ImageView imageView = (ImageView)findViewById(R.id.image);
    imageView.setImageResource(resid[0]);
    d.show();
    return false;
}

在这一行:imageView.setImageResource(resid[0]);

1 个答案:

答案 0 :(得分:1)

没有渣油很难说,但渣油是否为空?渣油中有多少元素? imageView是否为null?