无法根据Firebase

时间:2017-03-02 14:16:51

标签: android json firebase firebase-realtime-database

我是firebase的新手,并且正在尝试根据电子邮件ID向回收者视图显示数据,但是回收者视图显示了它的行。 这是我的onCreate方法。

     mDatabase= FirebaseDatabase.getInstance().getReference().child("user_project_status");
        //mDatabase.child(email);
        mDatabase.keepSynced(true);
        projects_token=(RecyclerView)findViewById(R.id.selected_projects);

        projects_token.setHasFixedSize(true);
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this);
        linearLayoutManager.setReverseLayout(true);
        linearLayoutManager.setStackFromEnd(true);
        projects_token.setLayoutManager(linearLayoutManager);
 LayoutInflater li = LayoutInflater.from(Status.this);
        //Creating a view to get the dialog box
        View confirmDialog = li.inflate(R.layout.pageloader, null);

        ImageView imageView = (ImageView) confirmDialog.findViewById(R.id.mImageLoading);
        Animation animation1 = AnimationUtils.loadAnimation(Status.this,
                R.anim.flip_anim);
        imageView.setAnimation(animation1);
        //Creating an alert dialog builder
        alert = new AlertDialog.Builder(Status.this);

        //Adding our dialog box to the view of alert dialog
        alert.setView(confirmDialog);
      //  alert.setCancelable(false);
        alertDialog = alert.create();
        alert.setCancelable(false);
        //Displaying the alert dialog
        alertDialog.show();
        FirebaseRecyclerAdapter<Status_getter,StatusViewHolder> firebaseRecyclerAdapter=new FirebaseRecyclerAdapter<Status_getter, StatusViewHolder>(Status_getter.class,R.layout.status_row,StatusViewHolder.class,mDatabase.equalTo("email",email)) {

            @Override
            protected void populateViewHolder(StatusViewHolder viewHolder, Status_getter model, int position) {
                final String post_key=getRef(position).getKey();
                if(model.getEmail().equals(email)) {
                    viewHolder.setProject_name(model.getProject_name());
                    viewHolder.setToken_no(model.getToken_no());
                    alertDialog.dismiss();
                }else{

                    alertDialog.dismiss();
                }

                viewHolder.mView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        Intent i=new Intent(Status.this,Selected_Status.class);
                        i.putExtra("status_id",post_key);
                        startActivity(i);
                    }
                });
            }

        };


        projects_token.setAdapter(firebaseRecyclerAdapter);

这是我的status_getter类,通过它我可以设置我的数据。用名称模型调用它

   String token_no,email,progress_dialog,progress_message,project_name,project_description,software_type;
    public Status_getter(){

    }
    public Status_getter(String token_no, String email, String progress_dialog, String progress_message, String project_name, String project_description, String software_type) {
        this.token_no = token_no;
        this.email = email;
        this.progress_dialog = progress_dialog;
        this.progress_message = progress_message;
        this.project_name = project_name;
        this.project_description = project_description;
        this.software_type = software_type;
    }

    public String getToken_no() {
        return token_no;
    }

    public void setToken_no(String token_no) {
        this.token_no = token_no;
    }

    public String getSoftware_type() {
        return software_type;
    }

    public void setSoftware_type(String software_type) {
        this.software_type = software_type;
    }

    public String getProject_description() {
        return project_description;
    }

    public void setProject_description(String project_description) {
        this.project_description = project_description;
    }

    public String getProject_name() {
        return project_name;
    }

    public void setProject_name(String project_name) {
        this.project_name = project_name;
    }

    public String getProgress_message() {
        return progress_message;
    }

    public void setProgress_message(String progress_message) {
        this.progress_message = progress_message;
    }

    public String getProgress_dialog() {
        return progress_dialog;
    }

    public void setProgress_dialog(String progress_dialog) {
        this.progress_dialog = progress_dialog;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

我创建了一个xml行,即“Status_row”,它创建了一个自定义的Recyclerview。

存储在我的数据库中的值就是这样。

1

0 个答案:

没有答案