gpt4 book ai didi

java - 搜索 Firestore 查询不在 RecycleView 中显示数据

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

这是我在 Firestore 中的数据 I want to show this name "mouad"

这是我的代码

ublic class SearchActivity extends AppCompatActivity {    private RecyclerView mMainList;    private FirebaseFirestore mFirestore;    private List usersList;    private CustomAdapter adapterRe;    EditText editText;    Button btnSearch;    String  name;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_search_firebase);        mFirestore = FirebaseFirestore.getInstance();        editText = (EditText) findViewById(R.id.search);        btnSearch = (Button) findViewById(R.id.btn);        usersList = new ArrayList();        adapterRe = new CustomAdapter(getApplicationContext(), usersList);        mMainList = (RecyclerView) findViewById(R.id.recyvle);      //  mMainList.setHasFixedSize(true);     //   mMainList.setLayoutManager(new LinearLayoutManager(this));     //   mMainList.setAdapter(adapterRe);        btnSearch.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                SearchUserFirebase();            }        });    }    private void SearchUserFirebase() {        name = editText.getText().toString();        if(!name.isEmpty()){            Query query =  mFirestore.collection("Movies").orderBy("name" ).startAt(name).endAt(name + "\uf8ff");            query.addSnapshotListener(new EventListener() {               @Override               public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {                   if (e != null){                       Log.d("TAG", "Error : " + e.getMessage());                   }                   ArrayList adsList = new ArrayList();                   for(DocumentChange doc : documentSnapshots.getDocumentChanges()){                       if (doc.getType() == DocumentChange.Type.ADDED){                           Movies users = doc.getDocument().toObject(Movies.class);                           usersList.add(users);                           adapterRe.notifyDataSetChanged();                       }                   }                   Log.d("TAG", "no of records of the search is " + adsList.size());               }           });        }    }    }

这是错误

error

最佳答案

“Movies.java”文件中是否有一个空的构造函数?

 public Movies() {
//Necessary to retrieve data
}

关于java - 搜索 Firestore 查询不在 RecycleView 中显示数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51446495/

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