1.popwindow嵌套了recyclerview,但是不顯示內(nèi)容
2.相關(guān)代碼如下
popwindow布局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>
適配器代碼--------------------------------------------------------------------------
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) {
//設(shè)置RecyclerView的源item.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) {
//通過(guò)position位置找到每個(gè)列表子項(xiàng),并用Intelligent對(duì)象存儲(chǔ)
//為子項(xiàng)view設(shè)置屬性,值為family中存的字段
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內(nèi)部類是必須實(shí)現(xiàn)的*/
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;
/*
* 在 ViewHolder內(nèi)部類里初始化布局中的view
* */
ViewHolder(View itemView) {
super(itemView);
//注意這里的view和Activity不一樣,通過(guò)參數(shù)itemView來(lái)find
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);
}
}
}
綁定適配器:-------------------------------------------------------------------------
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.報(bào)錯(cuò)信息:RecyclerView: No adapter attached; skipping layout
4.試過(guò)很多方法如:把線性布局換成相對(duì)布局、初始化時(shí)候setadapter、更新數(shù)據(jù)源family_adapter.notifyDataSetChanged()、clean&&rebuild.........始終找不出原因,難道是因?yàn)槲野裵opwindow放在fragment中導(dǎo)致的?找了一周原因了,請(qǐng)大神們幫幫忙吧,不勝感激!
我有幾個(gè)問(wèn)題想問(wèn)你,
1.recyclerview是在popwindows里面嗎?
2.你是列表的內(nèi)容不能顯示,還是popwindow根本彈不出來(lái)?
你是不是這里沒(méi)有
沒(méi)有設(shè)置背景?
下面是我做的一個(gè)demo,這個(gè)是效果
代碼路徑為:
https://github.com/love0829/l...
歡迎star
北大青鳥(niǎo)APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國(guó)家
北大青鳥(niǎo)中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過(guò)二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機(jī)構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
曾工作于聯(lián)想擔(dān)任系統(tǒng)開(kāi)發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_(kāi)發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開(kāi)發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開(kāi)發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開(kāi)發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問(wèn),美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。