首页 > 代码库 > android-The method findViewById(int) is undefined for the type ContactMainFragment报错

android-The method findViewById(int) is undefined for the type ContactMainFragment报错

 

    @Override    public void onViewCreated(View view, Bundle savedInstanceState) {        super.onViewCreated(view, savedInstanceState);                mTitleNameView = (TextView) findViewById(R.id.ivTitleName);        mTitleNameView.setVisibility(View.VISIBLE);        mTitleNameView.setText(R.string.company_name);

提示:意思应该是提示找不到相应组件而得不到组件ID

解决方法:加上view.即可

mTitleNameView = (TextView) view.findViewById(R.id.ivTitleName);

 

android-The method findViewById(int) is undefined for the type ContactMainFragment报错