Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无适配器连接;跳过布局跳过1到2帧_Java_Android - Fatal编程技术网

Java 无适配器连接;跳过布局跳过1到2帧

Java 无适配器连接;跳过布局跳过1到2帧,java,android,Java,Android,我试着寻找答案,但没有一个有效,但我相信这段代码是一个问题,调试器说 以下是指向我的文件的链接: 跳过1帧!应用程序可能在其主线程上做了太多工作 //处理数据 ourdos=findviewbyd(R.id.ourdos); ourdos.setLayoutManager(新的LinearLayoutManager(本)); 列表=新的ArrayList(); //从firebase获取数据 reference=FirebaseDatabase.getInstance().getReferenc

我试着寻找答案,但没有一个有效,但我相信这段代码是一个问题,调试器说

以下是指向我的文件的链接:

跳过1帧!应用程序可能在其主线程上做了太多工作

//处理数据
ourdos=findviewbyd(R.id.ourdos);
ourdos.setLayoutManager(新的LinearLayoutManager(本));
列表=新的ArrayList();
//从firebase获取数据
reference=FirebaseDatabase.getInstance().getReference().child(“SeaLab13”);
addValueEventListener(新的ValueEventListener(){
@凌驾
公共void onDataChange(DataSnapshot DataSnapshot){
//设置代码以检索数据并替换布局
对于(DataSnapshot dataSnapshot1:DataSnapshot.getChildren())
{
mydos p=dataSnapshot1.getValue(mydos.class);
增加(p);
}
doesAdapter=新doesAdapter(MainActivity.this,list);
setAdapter(doesAdapter);
doesAdapter.notifyDataSetChanged();
}
@凌驾
已取消的公共void(DatabaseError DatabaseError){
//设置代码以显示错误
Toast.makeText(getApplicationContext(),“无数据”,Toast.LENGTH_SHORT.show();
}
});
在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);
在适配器类中,创建一个函数来更新适配器的数据集:

public void updateData(ArrayList<MyDataType> newDataSet){
    myAdapterDataSet = newDataSet;

    // Let the Adapter know the data has changed and the view should be refreshed
    notifyDataSetChanged();
}
public void updateData(ArrayList newDataSet){
myAdapterDataSet=newDataSet;
//让适配器知道数据已更改,应该刷新视图
notifyDataSetChanged();
}

这是否回答了您的问题@SammyT hello您能修改我的代码吗?因为我在您提供的链接中看到了您的代码,但我不明白我需要更改代码的哪一部分。谢谢您阅读了关于导致此错误的原因的说明吗?你需要澄清什么部分?@SammyT是的,代码和关于错误的解释是相似的,我想这是因为我和他一样看了同一个教程。你介意看一下并修改我的代码吗?我会给你链接谢谢@SammyT它现在工作了,但是我还有一个问题,调试器说:我/编舞:跳过了8帧!应用程序可能在其主线程上做了太多工作。我/编舞:跳过76帧!应用程序可能在其主线程上做了太多工作。我/编舞:跳过172帧!应用程序可能在其主线程上做了太多工作。我/编舞:跳过了350帧!应用程序可能在其主线程上做了太多工作。一旦跳转到超过200帧,应用程序frezee@IanIndratama你需要研究Android的线程和后台处理。
@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);
}
public void updateData(ArrayList<MyDataType> newDataSet){
    myAdapterDataSet = newDataSet;

    // Let the Adapter know the data has changed and the view should be refreshed
    notifyDataSetChanged();
}