为什么我这个findviewbyid返回是空的

布局如下:
fragment_menu.xml主要布局
android:id="@+id/vNavigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/transparent"
app:headerLayout="@layout/view_global_menu_header"
app:itemIconTint="#8b8b8b"
app:itemTextColor="#666666"
app:menu="@menu/drawer_menu"/>
view_global_menu_header.xml
android:id="@+id/vGlobalMenuHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/ivMenuUserProfilePhoto"
        android:layout_width="@dimen/global_menu_avatar_size"
        android:layout_height="@dimen/global_menu_avatar_size"
        android:layout_margin="12dp" />

</LinearLayout>

然后是获取
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_menu, container,
false);
ivMenuUserProfilePhoto = (ImageView) view.findViewById(R.id.ivMenuUserProfilePhoto);

            但是这个ivMenuUserProfilePhoto返回是null,这是为什么啊?看着好像没问题啊

或者去本工程的相近页面拷贝过来import

在xml文件保存一下。

看看你的项目是否存在错误?存在的话,改一下错误。在写ivMenuUserProfilePhoto = (ImageView) view.findViewById(R.id.ivMenuUserProfilePhoto);

代码不全,不好分析也

ivMenuUserProfilePhoto = (ImageView) view.findViewById(R.id.ivMenuUserProfilePhoto);

鼠标放在R.id.ivMenuUserProfilePhoto上,按ctrl键,看下可以跳转到xml文件不

首先看看你的view是不是空的、

view里面的children里的mListener报错的是null

这个在哪里?怎么没看到?