提问者:小点点

我的Recyclerview布局在不工作相当一段时间后没有显示。 它显示已返回中继


上一次我在开发我的应用程序时,它的运行情况和预期的一样良好。 经过一个月的不工作,它没有弹出的布局,当我上次工作它。 当我点击按钮时,它将直接进入一个空白页

适配器

public class RestaurantAdapter extends FirebaseRecyclerAdapter<RestaurantDetails,RestaurantAdapter.RestaurantViewHolder> {


public RestaurantAdapter(@NonNull FirebaseRecyclerOptions<RestaurantDetails> options) {
    super(options);
}

FirebaseRecyclerOptions<RestaurantDetails> options =
        new FirebaseRecyclerOptions.Builder<RestaurantDetails>()
                .setQuery(FirebaseDatabase.getInstance().getReference().child("Restaurant").child("Info"), RestaurantDetails.class)
                .build();



@Override
protected void onBindViewHolder(@NonNull RestaurantViewHolder holder, final int position, @NonNull final RestaurantDetails details) {

    holder.restaurant_Name.setText(details.getName());
    holder.restaurant_Category.setText(details.getCategory());
    holder.restaurant_Location.setText(details.getLocation());

    Picasso.get().load(details.getImage()).into(holder.restaurant_Image);


    holder.itemView.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View view){
            String post_key = getRef(position).getKey();

            Intent intent = new Intent(view.getContext(), RestaurantInfoActivity.class);
            intent.putExtra("post_key", post_key);
            view.getContext().startActivity(intent);

        }
    });
}

@NonNull
@Override
public RestaurantViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    View view =LayoutInflater.from(parent.getContext())
            .inflate(R.layout.restaurant_list,parent, false);
    return new RestaurantViewHolder(view);
}

class RestaurantViewHolder extends RecyclerView.ViewHolder{

    TextView restaurant_Name, restaurant_Category,restaurant_Location;
    ImageView restaurant_Image;

    public RestaurantViewHolder(@NonNull View itemView){
        super(itemView);
        restaurant_Name = itemView.findViewById(R.id.restaurant_Name);
        restaurant_Category = itemView.findViewById(R.id.restaurant_Category);
        restaurant_Location = itemView.findViewById(R.id.restaurant_Location);
        restaurant_Image = itemView.findViewById(R.id.restaurant_Image);

    }
}

}

ResRecyclerViewActivity

public class ResRecyclerViewActivity extends AppCompatActivity {

private static final String TAG = "ResRecyclerViewActivity";
private RecyclerView restaurantRecyclerView;
private RestaurantAdapter adapter;

protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_restaurantlist);
    Log.d(TAG, "onCreate: started.");

    restaurantRecyclerView = findViewById(R.id.restaurant_rv);
    restaurantRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    FirebaseRecyclerOptions<RestaurantDetails> options =
            new FirebaseRecyclerOptions.Builder<RestaurantDetails>()
                    .setQuery(FirebaseDatabase.getInstance().getReference().child("Restaurant").child("Info"), RestaurantDetails.class)
                    .build();

    adapter = new RestaurantAdapter(options);
    restaurantRecyclerView.setAdapter(adapter);

}

@Override
protected void onStart() {
    super.onStart();
    adapter.startListening();
}

@Override
protected void onStop() {
    super.onStop();
    adapter.stopListening();
}

}

RestaurantDetails(模型)

public class RestaurantDetails {
private String name;
private String location;
private String address;
private String category;
private String image;
private Double latitude;
private Double longitude;


public RestaurantDetails(String name, String location, String address, String category, String image, Double latitude, Double longitude) {
    this.name = name;
    this.location = location;
    this.address = address;
    this.category = category;
    this.image = image;
    this.latitude = latitude;
    this.longitude = longitude;

}

public RestaurantDetails() {
}



public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getImage() {
    return image;
}

public void setImage(String image) { this.image = image; }

public String getLocation() {
    return location;
}

public void setLocation(String location) {
    this.location = location;
}

public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}

public String getCategory() {
    return category;
}

public void setCategory(String category) {
    this.category = category;
}

public Double getLatitude() {return latitude;}

public void setLatitude(Double lang) {this.latitude = latitude;}

public Double getLongitude() {return longitude;}

public void setLongitude(Double longitude) {this.longitude = longitude;}

}

当我调试应用程序时,这是弹出的评论。 未显示错误


共1个答案

匿名用户

可能是因为火力点的规定。 检查您的firebase数据库规则,因为一个月后,firebase规则出于安全原因更改为默认。