android-The method findViewById(int) is undefined for the type ContactMainFragment报错_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > android-The method findViewById(int) is undefined for the type ContactMainFragment报错

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

 2014/10/30 18:04:52  jenson138  程序员俱乐部  我要评论(0)
  • 摘要:@OverridepublicvoidonViewCreated(Viewview,BundlesavedInstanceState){super.onViewCreated(view,savedInstanceState);mTitleNameView=(TextView)findViewById(R.id.ivTitleName);mTitleNameView.setVisibility(View.VISIBLE);mTitleNameView.setText(R.string
  • 标签:android for view

 

    @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);

 

发表评论
用户名: 匿名