找不到id fragment_home的视图

时间:2016-11-07 21:57:30

标签: android fragment

fargment_home

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.shashank.iccca.test"
android:id="@+id/container"
>
<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="@string/hello_blank_fragment" />

main_activity java

if (id == R.id.home)
    {
        Home home=new Home();
        FragmentManager manager=getSupportFragmentManager();
        manager.beginTransaction().replace(R.id.container1,home,home.getTag()).commit();

这里主要是当我点击按钮时它会给出致命的异常错误

1 个答案:

答案 0 :(得分:0)

R.id.container1重命名为R.id.container