【问题标题】:Why the FirebaseRecyclerAdapter is not comming? [closed]为什么 FirebaseRecyclerAdapter 没有启动? [关闭]
【发布时间】:2017-09-18 02:04:37
【问题描述】:

没有出现任何建议,如果手动编写它会给出一个错误,告诉我要上课。 (我正在尝试从 firebase 检索数据并将其放在回收站视图中......!使用 Firebase 回收站适配器。)

public class Main_Page extends AppCompatActivity
    implements NavigationView.OnNavigationItemSelectedListener {

FirebaseAuth mFirebaseAuth;
FirebaseAuth.AuthStateListener mAuthStateListener;
GoogleApiClient mGoogleApiClient;

//Recycler view
private RecyclerView mTodoList;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main__page);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    //Firebase Auth
    mFirebaseAuth = FirebaseAuth.getInstance();
    mAuthStateListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            if (firebaseAuth.getCurrentUser() == null) {
                finish();
                startActivity(new Intent(Main_Page.this, SignIn.class));

            }
        }
    };

    FloatingActionButton fab = (FloatingActionButton) 
findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
            startActivity(new Intent(Main_Page.this, Add_To_Do.class));
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, 
R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) 
findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);


    //Recycler View
    mTodoList = (RecyclerView) findViewById(R.id.todo_list);
    mTodoList.setHasFixedSize(true);
    mTodoList.setLayoutManager(new LinearLayoutManager(this));

}







@Override
protected void onStart() {
    super.onStart();
    mFirebaseAuth.addAuthStateListener(mAuthStateListener);

    /*If i write FirebaseRecyclerAdapter it is not showing any suggestions
and if i write it manually i am getting an redline and it tells me to make a 
class or a function*/
    FirebaseRecy

}

//Recycler View
public  static class ToDoViewHolder extends RecyclerView.ViewHolder{

    View mView;

    public ToDoViewHolder(View itemView) {
        super(itemView);

        mView = itemView;
    }

    public void setLabel(String label){
        TextView post_label = (TextView) 
mView.findViewById(R.id.post_label);
        post_label.setText(label);
    }

    public  void setNote(String note){
        TextView post_note = (TextView) mView.findViewById(R.id.post_note);
        post_note.setText(note);
    }


}

@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main__page, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        mFirebaseAuth.signOut();
    }

    return super.onOptionsItemSelected(item);
}

@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camera) {
        // Handle the camera action
    } else if (id == R.id.nav_gallery) {

    } else if (id == R.id.nav_slideshow) {

    } else if (id == R.id.nav_manage) {

    } else if (id == R.id.nav_share) {

    } else if (id == R.id.nav_send) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
}    

Error Screenshot

Build.Gradle

【问题讨论】:

  • 你不能只是复制粘贴文件的内容而不是添加图像吗?
  • 由于列出的错误导致无法同步 Gradle 文件时没有建议
  • 第一个图像不起作用。我建议您在此站点中阅读有关 How to Ask a QuestionHow to create a Minimal, Complete, and Verifiable example 的信息。
  • @TDG 代码已添加...!!!!
  • @Teocci 对不起,我是新手.. 添加了代码和屏幕截图..

标签: android firebase firebase-realtime-database android-recyclerview


【解决方案1】:

添加这个:

com.firebaseui:firebase-ui-database:0.4.0 in build.Gradle

【讨论】:

  • 谢谢它的工作原理
猜你喜欢
  • 2012-04-15
  • 1970-01-01
  • 2015-08-23
  • 2021-09-12
  • 2013-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-01
相关资源
最近更新 更多