待处理集合下的所有文档都在RecyclerView中列出,如屏幕截图所示。单击特定项目时,将显示带有3个选项的“警报”对话框。单击“ 已发货”选项后,我要将状态字段的值从该特定项目的“ 已订购”更改为“ 已发货” 。该怎么做?请帮忙。
holder.cl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CharSequence options[] = new CharSequence[]{
"Shipped", "Out for Delivery", "Delivered"
};
AlertDialog.Builder builder = new AlertDialog.Builder(CheckOrders.this);
builder.setTitle("What's the order status?");
builder.setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
if (i == 0){
db.collection("Pending").get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()){
for (QueryDocumentSnapshot document : task.getResult()){
db.collection("Pending").document(String.valueOf(documentSnapshots.get(position).getData().replace("status", "shipped")));
}
}
}
});
}else if (i==1){
OutforDelivery();
}
else if (i==2){
Delivered();
}else {}
}
});
builder.show();
}
});