I keep getting a blank screen on my app but no errors and my Firebase contains data.
(我的应用程序上始终出现黑屏,但没有错误,我的Firebase包含数据。)
It looks like its not retrieved correctly. (看起来好像未正确检索。)
I have checked out answers from other similar questions, tried the solutions but i still cannot find the solution to my problem. (我已经检查了其他类似问题的答案,尝试了解决方案,但仍然找不到我的问题的解决方案。)
Kindly help am a bit new to this. (请对此有所帮助。)
This is my OrderStatus class
(这是我的OrderStatus类)
public class OrderStatus extends AppCompatActivity {
public RecyclerView recyclerView;
public RecyclerView.LayoutManager layoutManager;
FirebaseDatabase database;
DatabaseReference requests;
FirebaseRecyclerAdapter<DeliveryRequest, OrderViewHolder> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_order_status);
database = FirebaseDatabase.getInstance();
requests = database.getReference("OrderRequests");
recyclerView = (RecyclerView)findViewById(R.id.listOrders);
//ADAPTER
loadOrders();
}
private void loadOrders() {
FirebaseRecyclerOptions<DeliveryRequest> options =
new FirebaseRecyclerOptions.Builder<DeliveryRequest>()
.setQuery(requests, new SnapshotParser<DeliveryRequest>() {
@NonNull
@Override
public DeliveryRequest parseSnapshot(@NonNull DataSnapshot snapshot) {
return null;
}
})
.build();
adapter = new FirebaseRecyclerAdapter<DeliveryRequest, OrderViewHolder>(options) {
@Override
public OrderViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// Create a new instance of the ViewHolder, in this case we are using a custom
// layout called R.layout.message for each item
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.order_layout, parent, false);
return new OrderViewHolder(view);
}
@Override
protected void onBindViewHolder(OrderViewHolder holder, int position, DeliveryRequest model) {
// Bind the Chat object to the ChatHolder
// ...
holder.txtOrderPhone.setText(model.getPhone());
holder.txtOrderAddress.setText(model.getAddress());
holder.txtOrderStatus.setText(convertCodeToStatus(model.getStatus()));
holder.txtOrderId.setText(adapter.getRef(position).getKey());
}
};
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
adapter.startListening();
}
private String convertCodeToStatus(String status){
if (status.equals("0"))
return "placed";
else if (status.equals("1"))
return "on my way";
else
return "Shipped";
}
}
My String class
(我的弦乐课)
public class DeliveryRequest {
public String firstName, lastName,address, phone,total, status;
public List<ProposalDetails> proposalDetails;
public DeliveryRequest() {
}
public DeliveryRequest(String firstName,String lastName, String address,String phone,String total,String status, List<ProposalDetails> proposalDetails){
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
this.phone = phone;
this.proposalDetails = proposalDetails;
this.status = "0";
this.total= total;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public List<ProposalDetails> getProposalDetails() {
return proposalDetails;
}
public void setProposalDetails(List<ProposalDetails> proposalDetails) {
this.proposalDetails = proposalDetails;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getTotal() {
return total;
}
public void setTotal(String total) {
this.total = total;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
ask by UltraServe tech Solutions translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…