1.popwindow nests recyclerview, but does not display content
2. The related code is as follows:
popwindow layout xml--
xml version= "1.0" encoding= "utf-8"? >
< FrameLayout xmlns:android= "http://schemas.android.com/apk/res/android"
android:id="@+id/fl_familyList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@+id/rl_family"
android:background="@color/colorRlBg">
<RelativeLayout
android:id="@+id/ly_family_list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_mfamily_list"
android:layout_width="match_parent"
android:layout_height="200dp">
</android.support.v7.widget.RecyclerView><!---->
</RelativeLayout>
< / FrameLayout >
adapter code--
public class RvFamilyAdapter extends RecyclerView.Adapter < RvFamilyAdapter.ViewHolder > {
private List<Family> mfamilyList;
public RvFamilyAdapter(List<Family> familyList) {
mfamilyList = familyList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//RecyclerViewitem.xml
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.family_familylist_recyclerview_item, parent, false);
ViewHolder holder = new ViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull RvFamilyAdapter.ViewHolder holder, int position) {
//positionIntelligent
//viewfamily
holder.tv_family_name.setText(mfamilyList.get(position).getFamilyName());
holder.tv_family_owner_name.setText(mfamilyList.get(position).getFamilyOwner());
}
@Override
public int getItemCount() {
return mfamilyList.size();
}
/*ViewHolder*/
static class ViewHolder extends RecyclerView.ViewHolder {
ImageView iv_family_is_true;
ImageView iv_family_logo;
TextView tv_family_name;
TextView tv_family_character;
TextView tv_family_owner_name;
/*
* ViewHolderview
* */
ViewHolder(View itemView) {
super(itemView);
//viewActivityitemViewfind
iv_family_is_true = itemView.findViewById(R.id.iv_family_is_true);
iv_family_logo = itemView.findViewById(R.id.iv_family_logo);
tv_family_name = itemView.findViewById(R.id.tv_family_name);
tv_family_character = itemView.findViewById(R.id.tv_family_character);
tv_family_owner_name = itemView.findViewById(R.id.tv_family_owner_name);
}
}
}
bind adapter:--
private void handRecyList () {
View view = LayoutInflater.from(getActivity()).inflate(R.layout.family_popwindow_view,null);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv_mfamily_list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(linearLayoutManager);
family_adapter = new RvFamilyAdapter(getFamilyList());
recyclerView.setAdapter(family_adapter);
family_adapter.notifyDataSetChanged();
}
3. Error message: RecyclerView: No adapter attached; skipping layout
4. I have tried many methods, such as changing linear layout to relative layout, setadapter at initialization, updating data source family_adapter.notifyDataSetChanged (), clean&&rebuild.. I can"t find out the reason all the time. Is it because I put popwindow in fragment? I have been looking for the reason for a week. I would appreciate it if you would like to ask the gods to help me.