第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

無適配器連接的回收視圖;跳過布局

無適配器連接的回收視圖;跳過布局

ibeautiful 2019-06-05 14:34:48
無適配器連接的回收視圖;跳過布局剛剛在我的代碼中實(shí)現(xiàn)了回收視圖,取代了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));如您所見,我已經(jīng)為回收站..那么,為什么我總是收到這個(gè)錯(cuò)誤呢?我讀過與同一問題有關(guān)的其他問題,但沒有任何幫助。
查看完整描述

3 回答

?
尚方寶劍之說

TA貢獻(xiàn)1788條經(jīng)驗(yàn) 獲得超4個(gè)贊

我得到了相同的兩條錯(cuò)誤消息,直到我在代碼中修復(fù)了兩件事:

(1)默認(rèn)情況下,當(dāng)您在RecyclerView.Adapter它產(chǎn)生:

@Overridepublic int getItemCount() {
    return 0;}

請確保更新代碼,使其顯示:

@Overridepublic int getItemCount() {
    return artists.size();}

顯然,如果您在您的項(xiàng)目中有零項(xiàng),那么您將得到零的東西顯示在屏幕上。

(2)我并沒有如上邊答覆所示,這樣做:CardView布局_寬度=“匹配_父”不匹配父循環(huán)視圖寬度

//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);

(3)編輯:獎(jiǎng)勵(lì):也要確保設(shè)置好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" />

我已經(jīng)看過一些使用后一種方法的教程。當(dāng)它工作的時(shí)候,我認(rèn)為它也會產(chǎn)生這個(gè)錯(cuò)誤。


查看完整回答
反對 回復(fù) 2019-06-05
?
慕妹3146593

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超9個(gè)贊

我和你有同樣的情況,顯示是可以的,但是錯(cuò)誤出現(xiàn)在本地。這是我的解決方案:(1)初始化Create()上的ReccyclerView&BIND適配器

RecyclerView mRecycler = (RecyclerView) this.findViewById(R.id.yourid);mRecycler.setAdapter(adapter);

(2)當(dāng)您獲得數(shù)據(jù)時(shí)調(diào)用NotifyDataStateChanged

adapter.notifyDataStateChanged();

在回收視圖的源代碼中,還有其他線程來檢查數(shù)據(jù)的狀態(tài)。

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();
                }

            }
        }
    };

在DispatchLayout()中,我們可以發(fā)現(xiàn)其中存在錯(cuò)誤:

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 {


查看完整回答
反對 回復(fù) 2019-06-05
?
qq_花開花謝_0

TA貢獻(xiàn)1835條經(jīng)驗(yàn) 獲得超7個(gè)贊

您能確保從“主”線程(例如在“主”線程中)調(diào)用這些語句嗎?onCreate()方法)。當(dāng)我從“延遲”方法調(diào)用相同的語句時(shí)。就我而言ResultCallback我收到了同樣的信息。

在我的Fragment中調(diào)用下面的代碼。ResultCallback方法生成相同的消息。將代碼移動到onConnected()方法在我的應(yīng)用程序中,消息消失了.。

LinearLayoutManager llm = new LinearLayoutManager(this);llm.setOrientation(LinearLayoutManager.VERTICAL);list.setLayoutManager(llm);
list.setAdapter( adapter );


查看完整回答
反對 回復(fù) 2019-06-05
  • 3 回答
  • 0 關(guān)注
  • 665 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號