我希望能够搜索存储在我的Firestore数据库中的对象。 如果它是0,我想显示一个吐司错误。
public void afterTextChanged(Editable editable) {
// showSearchResults(editable.toString());
SubstanceSearch result = new SubstanceSearch(editable.toString());
Query query = result.getQuery();
database = FirebaseFirestore.getInstance();
adapter = setUpAdapter(database, query);
adapter.startListening();
setUpRecyclerView(recyclerView, adapter);
QuerySnapshot qs = query.get().getResult();
//QueryDocumentSnapshot qds = qs.getResult();
qs.size();
if(qs.isEmpty()){
Toast.makeText(SubstanceList.this, "no substance found", Toast.LENGTH_SHORT).show();
}
}
到达QuerySnapshot qs步骤时,它使应用程序崩溃。 我在做什么错了?