问题描述
我正在创建一个Instagram之类的社交应用。当我搜索用户并获得结果时,我想在单击其名称时转到其个人资料。但是现在我遇到了这个错误:
No view found for id 0x7f0800e0 (com.example.gone:id/fragment_container) for fragment 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>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)