Java 找不到片段ProfileFragment{89f1313的id 0x7f0800e0(com.example.go:id/fragment\u container)的视图

Java 找不到片段ProfileFragment{89f1313的id 0x7f0800e0(com.example.go:id/fragment\u container)的视图,java,android,android-studio,android-fragments,android-fragmentactivity,Java,Android,Android Studio,Android Fragments,Android Fragmentactivity,我正在创建一个像Instagram这样的社交应用程序。当我搜索一个用户并得到结果时,我想在单击他们的名字时转到他们的个人资料。但现在我遇到了以下错误: 未找到片段ProfileFragment{89f1313 因此,我尝试从SearchActivty转到ProfileFragment。我使用的代码与我的其他活动、适配器和片段中的代码相同。我在此处尝试了其他答案,但没有任何帮助。有人能告诉我为什么会出现此错误吗 @Override protected void onBindViewHolder(@

我正在创建一个像Instagram这样的社交应用程序。当我搜索一个用户并得到结果时,我想在单击他们的名字时转到他们的个人资料。但现在我遇到了以下错误:

未找到片段ProfileFragment{89f1313

因此,我尝试从
SearchActivty
转到
ProfileFragment
。我使用的代码与我的其他活动、适配器和片段中的代码相同。我在此处尝试了其他答案,但没有任何帮助。有人能告诉我为什么会出现此错误吗

@Override
protected void onBindViewHolder(@NonNull FindFriendsViewHolder holder, final int position, @NonNull User model) {

holder.userName.setText(model.getUsername());
holder.userFullName.setText(model.getFullname());
                    
Picasso.get().load(model.getImageurl()).placeholder(R.drawable.profile_pic)
.into(holder.profileImage);

holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
                            
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                                   new ProfileFragment()).commit();
        }
      });
}
activity_search.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SearchActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="10dp"
        android:orientation="horizontal"
        >

        <EditText
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:layout_marginHorizontal="5dp"
            android:hint="Search Username Here"
            android:textSize="22dp"
            android:id="@+id/input"
            android:inputType="text"
            android:layout_gravity="center"
            android:background="@drawable/round_edit_text" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Search"
            android:id="@+id/search"
            android:textSize="18dp"
            android:gravity="right"
            android:layout_marginRight="10dp"
            android:textStyle="bold"
            android:textColor="@color/colorPrimary"
            android:layout_gravity="center"
            />

    </LinearLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/recycler"></androidx.recyclerview.widget.RecyclerView>

</LinearLayout>


getSupportFragmentManager()
表示您正在使用活动的
FragmentManager
。请包括您用于活动的布局。@ianhanniballake我刚刚更新了我的问题,但getSupportFragmentManager不允许在适配器类中使用,您必须在适配器类中传递活动并调用它,如下所示(FragmentActivity)context).getSupportFragmentManager()它不是一个适配器类@Jersonso onBindViewholder从哪里来?我想它在适配器中?