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

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

未連接適配器;跳過布局跳過 1 到 2 幀

未連接適配器;跳過布局跳過 1 到 2 幀

搖曳的薔薇 2024-01-28 16:45:04
我嘗試尋找答案,但沒有任何效果,但我相信這段代碼是有問題的,調(diào)試器說這是我的文件的鏈接:TodoListApp跳過 1 幀!應(yīng)用程序可能在其主線程上做了太多工作// working with data    ourdoes = findViewById(R.id.ourdoes);    ourdoes.setLayoutManager(new LinearLayoutManager(this));    list = new ArrayList<MyDoes>();    // get data from firebase    reference = FirebaseDatabase.getInstance().getReference().child("SeaLab13");    reference.addValueEventListener(new ValueEventListener() {        @Override        public void onDataChange(DataSnapshot dataSnapshot) {            // set code to retrive data and replace layout            for(DataSnapshot dataSnapshot1: dataSnapshot.getChildren())            {                MyDoes p = dataSnapshot1.getValue(MyDoes.class);                list.add(p);            }            doesAdapter = new DoesAdapter(MainActivity.this, list);            ourdoes.setAdapter(doesAdapter);            doesAdapter.notifyDataSetChanged();        }        @Override        public void onCancelled(DatabaseError databaseError) {            // set code to show an error            Toast.makeText(getApplicationContext(), "No Data", Toast.LENGTH_SHORT).show();        }    });
查看完整描述

1 回答

?
猛跑小豬

TA貢獻(xiàn)1858條經(jīng)驗(yàn) 獲得超8個贊

在你的 onCreate 里面:


// Set up your RecyclerView with the appropriate Layout Manager

RecyclerView myRecycler = findViewById(R.id.my_recycler_id);

myRecycler.setLayoutManager(new LinearLayoutManager(this));


// Create your data set

myData = new ArrayList<MyDataType>();


// Create an instance of your adapter passing the data set into the constructor

myAdapter = new MyAdapter(this, myData);


// Set the Adapter on the RecyclerView directly within onCreate

// so that it doesn't get skipped

myRecycler.setAdapter(myAdapter);

在您的事件偵聽器回調(diào)中:


@Override

public void onDataChange(DataSnapshot snapshot){

    // Add the new data to your data set ex. myData.add(newData)

    // ...


    // After adding to the data set,

    // update the data using a custom function you define in your Adapter's class

    myAdapter.updateData(myData);

}

在 Adapter 類中,創(chuàng)建一個函數(shù)來更新 Adapter 的數(shù)據(jù)集:


public void updateData(ArrayList<MyDataType> newDataSet){

    myAdapterDataSet = newDataSet;


    // Let the Adapter know the data has changed and the view should be refreshed

    notifyDataSetChanged();

}


查看完整回答
反對 回復(fù) 2024-01-28
  • 1 回答
  • 0 關(guān)注
  • 130 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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