我在spinner
中实施了Alert Dialog
,其中包含一个成功更新Firebase数据库的更新按钮。这是通过此处的帮助实现的 - Updating Firebase records that are displayed in an Android ListView
但是,这些数据更新未反映在显示Firebase数据的ListView
中,它们只是保持不变。
有人可以帮助我在我的ListView
中显示这些内容吗?
这是我的showProgressDialog
:
private void showProgressDialog(final String id, String title, String description, String property, String maintenanceTitle) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.archive_maintenance, null);
dialogBuilder.setView(dialogView);
final Spinner spinnerProgress = (Spinner) dialogView.findViewById(R.id.spinnerProgress);
final Button buttonUpdateProgress = (Button) dialogView.findViewById(R.id.buttonUpdateProgress);
dialogBuilder.setTitle("Maintenance: " + maintenanceTitle);
final AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
buttonUpdateProgress.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String title = editTextTitle.getText().toString().trim();
String desc = editTextDesc.getText().toString().trim();
String progress = spinnerProgress.getSelectedItem().toString();
String property = spinnerProperty.getSelectedItem().toString();
updateProgress(title, desc, id, property, progress);
alertDialog.dismiss();
}
});
我的updateProgress
方法:
private boolean updateProgress (String title, String desc, String id, String property, String progress) {
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference().child("maintenance");
FirebaseUser user = mAuth.getCurrentUser();
String uid = user.getUid();
Map<String, Object> params = new HashMap<>();
params.put("progress", progress);
databaseReference.child(uid)
.child(id)
.updateChildren(params);
Toast.makeText(this, "Maintenance Updated Updated Successfully", Toast.LENGTH_LONG).show();
return true;
}
从我的数据结构中可以看出,节点progess
已更改为完成,但需要完成maintenanceProgress
。 progress
更改为Spinner
,然后更改为Button
。
非常感谢任何帮助。