【问题标题】:Error in adding a Fragment添加片段时出错
【发布时间】:2017-02-18 03:16:55
【问题描述】:

我正在使用 android.app.Fragment,有人请帮我理解为什么当我尝试将此片段添加到事务中时,我在 FG 下得到一个红线错误?我没有正确输入吗?我在下面添加了一个截图:

Screenshot

【问题讨论】:

    标签: android android-activity transactions fragment


    【解决方案1】:

    使用android.support.v4.app.Fragment并添加片段如下

    getSupportFragmentManager()
                .beginTransaction()
                .add(R.id.fragment_container, new Fragment_One())
                .addToBackStack(null)
                .commit();
    

    您的活动必须扩展AppCompatActivity

    【讨论】:

    • 非常感谢,成功了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-23
    • 2016-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多