【发布时间】:2019-11-01 22:33:13
【问题描述】:
我已经尝试寻找答案,但没有一个有效,但我相信这段代码有问题,调试器说
这是我文件的链接:TodoListApp
跳过了 1 帧!应用程序可能在其主线程上做了太多工作
// 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();
}
});
【问题讨论】:
-
@SammyT 你好,你能修改我的代码吗,因为我在你提供的链接中看到了你的代码,但我不明白我需要在哪一部分更改它。谢谢
-
您是否阅读了有关导致此错误的原因的说明?您需要澄清哪一部分?
-
@SammyT 是的,我做到了,关于错误的代码和解释是相似的,我认为那是因为我和他一样看了同样的教程
-
您介意查看和更改我的代码吗?我给你链接