在com.example.mayank.messaging.productDetail类上找不到详细信息的setter / field

时间:2017-08-25 07:02:46

标签: java android

从firebase读取数据的代码

        mChildEventListener = new ChildEventListener() {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {


                productDetail productdetails  = dataSnapshot.getValue(productDetail.class);
                 System.out.println("URL:"+ productdetails.getp_url());

            }

            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {

            }

            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {

            }

            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {

            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }

        };
    mMessageDatabaseReference.addChildEventListener(mChildEventListener);

class productDetail

enter code here

package com.example.mayank.messaging;

/**
 * Created by mayank on 22/8/17.
 */

public class productDetail {
String p_id ;
String p_cost ;
String p_url ;
String p_name ;


public productDetail() {

}

public productDetail(String p_id, String p_name, String p_cost, String p_url)
{
  this.p_id = p_id ;
  this.p_name = p_name ;
    this.p_cost = p_cost ;
    this.p_url = p_url ;


}

public String getp_id(){
    return(p_id) ;

}
public void setp_id(String p_id){
    this.p_id = p_id ;
}

public String getp_name(){
    return(p_name);
}
public void setp_name(String p_name){
    this.p_name = p_name ;
}

public String getp_cost(){
    return(p_cost) ;

}
public void setp_cost(String p_cost){
    this.p_cost = p_cost ;
}

public String getp_url(){
    return(p_url) ;

}
public void setp_url(String p_url){
    this.p_url = p_url ;
}

}

适配器类

enter code here

 package com.example.mayank.messaging;

 import android.app.Activity;
 import android.content.Context;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
 import android.widget.ImageView;
 import android.widget.TextView;


  import com.bumptech.glide.Glide;

  import java.util.List;

  /**
   * Created by mayank on 22/8/17.
  */

  public class PhotoAdapter extends ArrayAdapter<productDetail> {

  public PhotoAdapter(Context context, int resource, List<productDetail> objects){
    super(context, resource, objects);
    }

@Override
public View getView(int position , View converView, ViewGroup parent) {

    if(converView == null) {
        converView = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.product_detail, parent, false);

    }

    ImageView photoImageView = (ImageView) converView.findViewById(R.id.photoImageView);
    TextView product_id = (TextView) converView.findViewById(R.id.pid) ;
    TextView product_name = (TextView) converView.findViewById(R.id.pname) ;
    TextView product_cost = (TextView) converView.findViewById(R.id.pcost) ;

    productDetail product = getItem(position);

          Glide.with(photoImageView.getContext()).load(product.getp_url()).into(photoImageView);
    product_id.setText(product.getp_id()) ;

    product_name.setText(product.getp_name()) ;
    product_cost.setText(product.getp_cost()) ;

    return converView ;
}

}

错误

08-25 11:20:18.778 3961-3961/com.example.mayank.messaging W/ClassMapper: No setter/field for Detail found on class com.example.mayank.messaging.productDetail
08-25 11:20:18.778 3961-3961/com.example.mayank.messaging W/ClassMapper: No setter/field for Primekeys found on class com.example.mayank.messaging.productDetail
08-25 11:20:18.778 3961-3961/com.example.mayank.messaging W/ClassMapper: No setter/field for Messages found on class com.example.mayank.messaging.productDetail
08-25 11:20:18.778 3961-3961/com.example.mayank.messaging I/System.out: URL:null
08

firebase databse

1 个答案:

答案 0 :(得分:0)

试试这个.. !!!我认为..... 细节,Primekeys,消息没有setter方法。 创建它们或更改那些代表这3的那些。 您将继续出现此错误,因为在您的firebase数据库中,您有此字段,并且没有设置它们的方法.....