解决方案 »

  1.   

    删除以下代码:
    textView = (TextView)findViewById(R.id.textView);
    textView.setText("Hello Dylan");修改fragment的oncreateview
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {View rootView = inflater.inflate(R.layout.fragment_main, container,
    false);
    TextView textView = (TextView)rootView.findViewById(R.id.textView);
    textView.setText("Hello Dylan");
    return rootView;
    }
    }
      

  2.   

    不行,代码编译时会报错,说Cannot make a static reference to the non-static field textView
    后来我把textView属性改为static变量,显示没有出错感谢啊
      

  3.   

    不行,代码编译时会报错,说Cannot make a static reference to the non-static field textView
    后来我把textView属性改为static变量,显示没有出错感谢啊