无适配器连接的回收视图;跳过布局刚刚在我的代码中实现了回收视图,取代了Listview。一切正常。显示对象。但Logcat说15:25:53.476 E/回收器视图:没有连接适配器;跳过布局15:25:53.655 E/回收器视图:没有连接适配器;跳过布局为代码ArtistArrayAdapter adapter = new ArtistArrayAdapter(this, artists);recyclerView = (RecyclerView) findViewById(R.id.cardList);
recyclerView.setHasFixedSize(true);recyclerView.setAdapter(adapter);recyclerView.setLayoutManager(new LinearLayoutManager(this));如您所见,我已经为回收站..那么,为什么我总是收到这个错误呢?我读过与同一问题有关的其他问题,但没有任何帮助。
3 回答
尚方宝剑之说
TA贡献1788条经验 获得超4个赞
RecyclerView.Adapter
@Overridepublic int getItemCount() { return 0;}
@Overridepublic int getItemCount() { return artists.size();}
//correctLayoutInflater.from(parent.getContext()) .inflate(R.layout.card_listitem, parent, false);//incorrect (what I had)LayoutInflater.from(parent.getContext()) .inflate(R.layout.card_listitem,null);
RecyclerView
<android.support.v7.widget.RecyclerView android:id="@+id/RecyclerView" android:layout_width="match_parent" android:layout_height="match_parent" />
<view android:id="@+id/RecyclerView" class="android.support.v7.widget.RecyclerView" android:layout_width="match_parent" android:layout_height="match_parent" />
慕妹3146593
TA贡献1820条经验 获得超9个赞
RecyclerView mRecycler = (RecyclerView) this.findViewById(R.id.yourid);mRecycler.setAdapter(adapter);
adapter.notifyDataStateChanged();
public RecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); this.mObserver = new RecyclerView.RecyclerViewDataObserver(null); this.mRecycler = new RecyclerView.Recycler(); this.mUpdateChildViewsRunnable = new Runnable() { public void run() { if(RecyclerView.this.mFirstLayoutComplete) { if(RecyclerView.this.mDataSetHasChangedAfterLayout) { TraceCompat.beginSection("RV FullInvalidate"); RecyclerView.this.dispatchLayout(); TraceCompat.endSection(); } else if(RecyclerView.this.mAdapterHelper.hasPendingUpdates()) { TraceCompat.beginSection("RV PartialInvalidate"); RecyclerView.this.eatRequestLayout(); RecyclerView.this.mAdapterHelper.preProcess(); if(!RecyclerView.this.mLayoutRequestEaten) { RecyclerView.this.rebindUpdatedViewHolders(); } RecyclerView.this.resumeRequestLayout(true); TraceCompat.endSection(); } } } };
void dispatchLayout() { if(this.mAdapter == null) { Log.e("RecyclerView", "No adapter attached; skipping layout"); } else if(this.mLayout == null) { Log.e("RecyclerView", "No layout manager attached; skipping layout"); } else {
qq_花开花谢_0
TA贡献1835条经验 获得超7个赞
onCreate()
ResultCallback
Fragment
ResultCallback
onConnected()
LinearLayoutManager llm = new LinearLayoutManager(this);llm.setOrientation(LinearLayoutManager.VERTICAL);list.setLayoutManager(llm); list.setAdapter( adapter );
- 3 回答
- 0 关注
- 635 浏览
添加回答
举报
0/150
提交
取消