gpt4 book ai didi

Java if- else 字符串.contains 不起作用错误

转载 作者:行者123 更新时间:2023-12-02 12:00:54 24 4
gpt4 key购买 nike

如果我输入 entity.about = "phone"test = "phone" 则搜索列表会更新,但如果我输入 entity.about = “this isphone”test = “phone” 则搜索列表不会更新。

public void onSearchConfirmed(final CharSequence text) {
productsRef = FirebaseDatabase.getInstance().getReference("products");
searchList.clear();
final String test = text.toString();
productsRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
ProductEntity entity = postSnapshot.getValue(ProductEntity.class);
if(entity.about.contains(test) || entity.vendor_address.contains(test)) {
searchList.add(entity) ;
}
}
}
}
}

最佳答案

将代码:entity.about.contains(test)替换为entity.about.toLowerCase.contains(test)

关于Java if- else 字符串.contains 不起作用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47258021/

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