Android 无法解析符号';图像视图2';

Android 无法解析符号';图像视图2';,android,android-fragments,imageview,ontouchlistener,Android,Android Fragments,Imageview,Ontouchlistener,我试图在片段中创建ImageView,该片段将引用我在XML中为片段创建的ImageView元素: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState);

我试图在片段中创建ImageView,该片段将引用我在XML中为片段创建的ImageView元素:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);

        final View c = inflater.inflate(R.layout.activity_source, container, false);

        ImageView view = (ImageView) getView().findViewById(R.id.ImageView3);
        view.setOnTouchListener(this);

        return c;

    }
但是,尽管我认为它会起作用,但它无法解决“ImageView3”而不是

(ImageView)getView().findViewById(R.id.ImageView3)

使用


(ImageView)c.findViewById(R.id.ImageView3)

没有看到活动的xml源代码(您没有发布),我想

ImageView view = (ImageView) getView().findViewById(R.id.ImageView3);
应该是

ImageView view = (ImageView) c.findViewById(R.id.ImageView3);

我已经试过了,但是没有任何区别。我很抱歉给您添麻烦,我找到了,我的id在xml中是“imageView3”,在我的课堂上我写了“imageView3”。我想我该睡觉了,今天到此为止