```java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mBtnout = view.findViewById(R.id.btn_out);
mTextgroup = view.findViewById(R.id.text_group);
//设置适配器
listView = view.findViewById(R.id.list_item1);
listView.setAdapter(new GroupAdapter(getActivity()));
mBtnattend = view.findViewById(R.id.btn_attend);
mBtnattend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getFragmentManager().beginTransaction().replace(R.id.list_item1,partcipateFragment).commitAllowingStateLoss();
}
});
然后这个是布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:padding="15dp"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#E8CA88">
<Button
android:id="@+id/btn_out"
android:layout_marginLeft="15dp"
android:layout_marginTop="13dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:background="@drawable/fanhui"/>
<TextView
android:id="@+id/text_group"
android:layout_marginTop="7dp"
android:layout_centerHorizontal="true"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="xxx"/>
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal">
<Button
android:id="@+id/btn_group"
android:layout_width="400dp"
android:layout_height="40dp"
android:text="xxx"
android:layout_weight="1"
android:background="#fff"/>
<Button
android:id="@+id/btn_attend"
android:layout_weight="1"
android:layout_width="400dp"
android:layout_height="40dp"
android:text="xxx"
android:background="#fff"/>
</LinearLayout>
<LinearLayout
android:id="@+id/li_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView
android:id="@+id/list_item1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></ListView>
</LinearLayout>
</LinearLayout>