本帖最后由 u012745013 于 2014-03-28 12:20:08 编辑

解决方案 »

  1.   

    api19上面没有注明这样的区别啊,为啥会找不到id了,,,
      

  2.   

    我还是在mainactivity中的oncreate方法中用findviewbyid方法,结果就报空指针异常,我不知道去哪里找了
      

  3.   

     你的意思你再if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction()
                        .add(R.id.container, new PlaceholderFragment()).commit();
            }这句话后面findViewById会报错?
      

  4.   

    是的,我还是按照原来的习惯 button = (Button) this.findViewById(R.id.buttonzwb);
    textView = (TextView) this.findViewById(R.id.textView1);
    progressBar = (ProgressBar) this.findViewById(R.id.progressBar);
    editText = (EditText) this.findViewById(R.id.editText);

    // button.setOnClickListener(this);
    System.out.println(editText.getText().toString().trim());
      

  5.   

    我前几天看api的时候,没有注意到4.4有声明这项改动的,,,
      

  6.   

    查了下资料,别人说要在 View rootView = inflater.inflate(R.layout.fragment_main, container,
                        false);这里写
      

  7.   

    这是一个静态类,外面声明的里面不能用,里面 声明的外面也获取不到啊
    public static class PlaceholderFragment extends Fragment {
    public PlaceholderFragment() {
    } @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container,
    false);
    return rootView;
    }
    }
      

  8.   

    恩,我也不知道为啥原理,待我再去研究下,你先把问题结局,在那里findViewById就行
      

  9.   

    看下这个帖子http://bbs.csdn.net/topics/390742254
      

  10.   

    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.section_label);
    textView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));