Android java.lang.IllegalArgumentException:找不到片段SignFragment id的视图

Android java.lang.IllegalArgumentException:找不到片段SignFragment id的视图,android,android-fragments,Android,Android Fragments,我试图点击打开signfragment的按钮,但我得到了下面提到的崩溃: java.lang.IllegalArgumentException:未找到片段SignFragment{e65f679#3 id=0x7f0a03ca}的id 0x7f0a03ca的视图 这是我的活动课 public class MainActivity extends AppcompatActivity implements SignFragment.SignPadCallback{ setCont

我试图点击打开signfragment的按钮,但我得到了下面提到的崩溃: java.lang.IllegalArgumentException:未找到片段SignFragment{e65f679#3 id=0x7f0a03ca}的id 0x7f0a03ca的视图

这是我的活动课

   public class MainActivity extends AppcompatActivity implements SignFragment.SignPadCallback{
       setContentView(R.layout.activity_ordering_main);
        //on click of a button i called this method
        private void openSignPad() {
               Fragment fragment = SignFragment.getInstance(this);
                FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
                fragmentTransaction.add(R.id.orderingMainContainerfragment, fragment);
                fragmentTransaction.addToBackStack(null);
                fragmentTransaction.commit();
            }

        }
片段类

 import android.app.Fragment;
    public class SignFragment extends Fragment  implements View.OnClickListener {


        OrderingMainCallback orderingMainCallback;
        private SignPadCallback callBack;
        private LinearLayout signPadLayout;
        private DrawView drawView;
        private int padWidth;
        private int padHeight;


        public static Fragment getInstance(SignPadCallback callBack) {
            SignFragment fragment = new SignFragment();
            fragment.callBack = callBack;
            return fragment;
        }
    }
布局文件

 <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="horizontal">

            <LinearLayout
                android:id="@+id/linearLayout5"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:orientation="vertical"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toLeftOf="@+id/linearLayout6"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.0">

                <fragment
                    android:id="@+id/orderingMainContainerfragment"
                    android:name="com.android.emobilepos.ordering.newui.OrderingMainCatalogFragment"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    tools:layout="@layout/fragment_ordering_main_catalog" />

    </LinearLayout>
      <fragment
                    android:id="@+id/orderDetailsfragment3"
                    android:name="com.android.emobilepos.ordering.newui.OrderTotalDetailsFragment"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    tools:layout="@layout/fragment_order_total_details" />
    </LinearLayout>

使用以下代码:-

Fragment fragment = SignFragment.getInstance(this);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction()
fragmentTransaction.add(R.id.orderingMainContainerfragment, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
还有进口

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;

SignFragment类中缺少onCreateView

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    View view = inflater.inflate(R.layout.sign_fragment /* this will be the layout file for your fragment. */, container, false);

    return view;
}