gpt4 book ai didi

java - 将模型类中的数据赋值给数组,并根据传入的数据发送通知给用户

转载 作者:行者123 更新时间:2023-12-01 17:09:13 25 4
gpt4 key购买 nike

enter image description here我逐渐遇到两个问题,首先,我想从案例模型类中提取 getDavaTarih 字段并将其分配给一个数组

public class Davalar {

String davaTarihi, davaTuru, esasNo, kararNo, notlar, key;

public Davalar() {

}

public Davalar(String davaTarihi, String davaTuru, String esasNo, String kararNo, String notlar, String key) {
this.davaTarihi = davaTarihi;
this.davaTuru = davaTuru;
this.esasNo = esasNo;
this.kararNo = kararNo;
this.notlar = notlar;
this.key = key;
}

public String getDavaTarihi() {
return davaTarihi;
}

public String getDavaTuru() {
return davaTuru;
}

public String getEsasNo() {
return esasNo;
}

public String getKararNo() {
return kararNo;
}

public String getNotlar() {
return notlar;
}

public String getKey() {
return key;
}
}

我将数据添加到模型类的位置

public void davalariGetir() {
databaseReference.child(userId).orderByChild("davaTarihi").addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
Davalar davalar = dataSnapshot.getValue(Davalar.class);
if (davalarList.indexOf(dataSnapshot.getKey()) == -1) {
davalarList.add(new Davalar(davalar.getDavaTarihi(), davalar.getDavaTuru(),
davalar.getEsasNo(), davalar.getKararNo(),
davalar.getNotlar(), davalar.getKey()));
}

textView_dava_ekle.setText("");
image_view_ekle.setVisibility(View.INVISIBLE);

davalarAdapter.notifyDataSetChanged();

}

@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

}

@Override
public void onChildRemoved(@NonNull final DataSnapshot dataSnapshot) {

davalarList.remove(dataSnapshot.getKey());
davalarAdapter.notifyDataSetChanged();


}

@Override
public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});

在这个函数中,我想将所有 getDavaTarih 字段添加到字符串数组中我怎样才能做到这一点 ?然后我会回答我的另一个问题

我想获取模型类中显示的两个字段的摘要并将它们分配给字符串数组

最佳答案

我从您的评论中了解到,您正在尝试提取 davaTarihi,如果这是问题:

//after you filled the davalarList

for(int i=0 ; i<davalarList.size() ; i++){

//extract every davaTarihi and compare it with the current date

String davaTarihi = davalarList.get(i).getDavaTarihi();

//then notify whatever

}

关于java - 将模型类中的数据赋值给数组,并根据传入的数据发送通知给用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61440671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com