Account.java
public class Account {
private String _Phone;
private String _IC;
private String _FullName;
private List<String> _CarPlate;
public Account(){}
public Account(String fullname, String phone, List<String> carplate, String IC)
{
this._Phone=phone;
this._CarPlate=carplate;
this._FullName=fullname;
this._IC=IC;
}
public void set_CarPlate(List<String> CarPlate){this._CarPlate=_CarPlate;}
public List<String> get_CarPlate(){return _CarPlate;}
public void set_Phone(String _Phone) {
this._Phone = _Phone;
}
public String get_Phone() {
return _Phone;
}
public String get_IC() {
return _IC;
}
public void set_IC(String _IC){this._IC=_IC;}
public String get_FullName() {
return _FullName;
}
public void set_FullName(String _FullName){ this._FullName=_FullName;}
根据我的理解,
ChangeEmailPassword.java
List<String> names=new ArrayList<>();
changePhone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
progressBar.setVisibility(View.VISIBLE);
txtPhone = newPhone.getText().toString().trim();
if (!txtPhone.equals("")) {
mDatabase.child(user.getUid()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Account phoneAcc=new Account();
//从Firebase中检索所有数据 Map map =(Map)dataSnapshot.getValue(); //使用setter
将数据映射到Account.java进行封装 phoneAcc.set_FullName(map.get("_FullName"));
//创建新的List对象,并将数据添加到从Firebase检索的列表中
names.add(map.get("_CarPlate"));
phoneAcc.set_CarPlate(names);
phoneAcc.set_IC(map.get("_IC"));
phoneAcc.set_Phone(txtPhone);
//再次将所有值添加到firebase中以覆盖旧数据
mDatabase.child(user.getUid()).setValue(phoneAcc);
为什么我无法获取列表数据?
当我两次更新电话号码时的另一个问题是,它会给我这样的结果:
[![第二个结果] [3]] [3]
我的控制台的结果将是
I/Timeline: Timeline: Activity_launch_request time:63270425
I/Timeline: Timeline: Activity_launch_request time:63270472
I/Timeline: Timeline: Activity_launch_request time:63270520
I/Timeline: Timeline: Activity_launch_request time:63270576
I/Timeline: Timeline: Activity_launch_request time:63270638
I/Timeline: Timeline: Activity_launch_request time:63270680
.
.
.
不可阻挡的