2017-09-13 1 views
0

Im essayer de montrer dans le fragment montrent pas de données, mais je peux sur l'activitéFirebase Ui pas afficher les données dans firebase

Je suis utilisé comme même code de Firebase UI ne sais pas ce que je l'oublie et

ici mes données firebase

enter image description here

Mon résultat que je reçois

enter image description here

heritier mon code

SOS.Fragment

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    // Inflate the layout for this fragment 
    View view = inflater.inflate(R.layout.view_sos, container, false); 
    SupportMapFragment mapFragment = (SupportMapFragment)getChildFragmentManager().findFragmentById(R.id.map_report); 
    mapFragment.getMapAsync(this); 

    preferences = getActivity().getSharedPreferences(shared_preferences, Context.MODE_PRIVATE); 

    mRecyclerView = (RecyclerView)view.findViewById(R.id.rv_sos); 
    mRecyclerView.setHasFixedSize(true); 
    mLayoutManager = new LinearLayoutManager(getContext()); 


    mAuth = FirebaseAuth.getInstance(); 
    mRef = FirebaseDatabase.getInstance().getReference(); 



    mBtn = (ImageButton)view.findViewById(R.id.s_o_s_btn); 
    mBtn.setOnClickListener(this); 


       mAdapter = new FirebaseRecyclerAdapter<SOS, SoSViewHolder> 
         (
           SOS.class, 
           R.layout.sos_list, 
           SoSViewHolder.class, 
           mRef.child("report") 
         ) 
       { 
        @Override 
        protected void populateViewHolder(SoSViewHolder holder, SOS sos, int position) { 
         holder.setMtopic(sos.getRpTitle()); 
         holder.setMlocation(sos.getRpLocation()); 
        } 
       }; 

       mRecyclerView.setLayoutManager(mLayoutManager); 
       mAdapter.notifyDataSetChanged(); 
       mRecyclerView.setAdapter(mAdapter); 


    return view; 
} 

SOS Modèle

package com.enovagroup.army3.Model; 

/** * Créé par Android Dev sur 29/8/2560. */ public class SOS {

private String rpAddress; 
private String rpAuther; 
private String rpBody; 
private String rpCreate; 
private String rpId; 
private String rpLocation; 
private String rpPic; 
private Integer rpTimestamp; 
private String rpTitle; 

public SOS(){ 

} 

public SOS(String rpAddress, String rpAuther, String rpBody, String rpCreate, String rpId, String rpLocation, 
      String rpPic, Integer rpTimestamp, String rpTitle) { 
    this.rpAddress = rpAddress; 
    this.rpAuther = rpAuther; 
    this.rpBody = rpBody; 
    this.rpCreate = rpCreate; 
    this.rpId = rpId; 
    this.rpLocation = rpLocation; 
    this.rpPic = rpPic; 
    this.rpTimestamp = rpTimestamp; 
    this.rpTitle = rpTitle; 
} 

public void setRpAddress(String rpAddress) { 
    this.rpAddress = rpAddress; 
} 

public void setRpAuther(String rpAuther) { 
    this.rpAuther = rpAuther; 
} 

public void setRpBody(String rpBody) { 
    this.rpBody = rpBody; 
} 

public void setRpCreate(String rpCreate) { 
    this.rpCreate = rpCreate; 
} 

public void setRpId(String rpId) { 
    this.rpId = rpId; 
} 

public void setRpLocation(String rpLocation) { 
    this.rpLocation = rpLocation; 
} 

public void setRpPic(String rpPic) { 
    this.rpPic = rpPic; 
} 

public void setRpTimestamp(Integer rpTimestamp) { 
    this.rpTimestamp = rpTimestamp; 
} 

public void setRpTitle(String rpTitle) { 
    this.rpTitle = rpTitle; 
} 

public String getRpAddress() { 
    return rpAddress; 
} 

public String getRpAuther() { 
    return rpAuther; 
} 

public String getRpBody() { 
    return rpBody; 
} 

public String getRpCreate() { 
    return rpCreate; 
} 

public String getRpId() { 
    return rpId; 
} 

public String getRpLocation() { 
    return rpLocation; 
} 

public String getRpPic() { 
    return rpPic; 
} 

public Integer getRpTimestamp() { 
    return rpTimestamp; 
} 

public String getRpTitle() { 
    return rpTitle; 
} 

Sos ViewHolder

public class SoSViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 

public TextView mtopic , mlocation; 
private ItemClickListener itemClickListener; 
public String rptitle,rpbody,rpauther,rpaddress,rplocation; 

public SoSViewHolder(View view) { 
    super(view); 

    mtopic = (TextView)view.findViewById(R.id.sos_topic); 
    mlocation = (TextView)view.findViewById(R.id.sos_location); 

    view.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      Intent intent = new Intent(view.getContext(), SoSDetail.class); 

      intent.putExtra("rp_title",mtopic.getText().toString()); 
      intent.putExtra("rp_location",mlocation.getText().toString()); 
      intent.putExtra("rp_body",rpbody); 
      intent.putExtra("rp_title",rptitle); 
      intent.putExtra("rp_address",rpaddress); 
      intent.putExtra("rp_auther",rpauther); 
      intent.putExtra("rp_location",rplocation); 
     } 
    }); 
} 

public void setMtopic(String topic){ 
    mtopic.setText(topic); 
} 

public void setMlocation(String location){ 
    mlocation.setText(location); 
} 

J'espère que tout le monde peut Solove essayer mon problème im à quelque chose pour résoudre mon problème

Répondre

0

Vous avez différentes conventions de nommage dans votre base de données et votre code. Par exemple, rp_auther par rapport à rpAuther. L'adaptateur ne sait pas comment mapper ces valeurs, ce qui pourrait être la raison pour laquelle les données sont vides.

Vous pouvez renommer les noms de propriété dans la base de données ou ajouter des annotations @SerializedName("rp_auther") à votre classe pojo.

+0

Thx monsieur je pour obtenir ce long temps im done –