解决方案 »

  1.   

    setContentView(R.layout.fragment_main);
      

  2.   


    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main); TextView username=(TextView)findViewById(R.id.username);
    // username.setText(Html.fromHtml("Hello,大家好,<font color=red>我是你们的新导师</font>"));


    String userText="你知道我的名字吗";
    SpannableStringBuilder style=new SpannableStringBuilder(userText);
    style.setSpan(new ForegroundColorSpan(Color.RED), 1, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    username.setText(style);




    if (savedInstanceState == null) {
    getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
    }
    }
      

  3.   

    你的layout是什么名字就是什么呗
      

  4.   

    (⊙o⊙)哦 原来是layout下面的文件名字啊!!!我错了,我再试下
      

  5.   

    看看你class类顶部导入的是android.R.还是你自己工程里的R
      

  6.   

    删除下面这段代码
    if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
            }新版用不惯的话就下个老版本的Eclipse吧
      

  7.   

    删除下面这段代码
    if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
            }新版用不惯的话就下个老版本的Eclipse吧已经解决啦,引用的layout下的哪个文件 就在哪个文件下创建TextView,报错是因为创建的和引用的不同,此贴终结,多谢各位帮解释