Briefly about the problem. I decided to try using RecyclerView. A ready-made search solution as a listView is not there, you need to implement everything yourself. So I found a solution, if anyone needs the source below, but there is a problem.
There is a list in it that displays headers; when you click on any item, I switch to the second activation where there is already a title and a full description.
I implemented it like this:
In the MainActivity I load from the database (using the Sugar ORM) headers and id
ArrayList<String> arrTitle = new ArrayList<>(); for(Contact contact:allContacts){ arrTitle.add(contact.title); } ArrayList<String> arrId = new ArrayList<>(); for(Contact contact:allContacts){ long i = contact.getId(); String str = Long.toString(i); arrId.add(str); // or arr.add(contact.name); if it's public } Then I transfer them to Adaptar.
mAdapter = new RecyclerAdapter(arrTitle, arrId); in the RecyclerAdapter Adapter I get these values, the title is listed, and id is passed to the second Activiti
@Override public void onBindViewHolder(ViewHolder holder, int position) { // ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΡΡ id Π² ΠΌΠ°ΡΡΠΈΠ² idTab = new String[mId.size()]; for (int i = 0; i != mId.size(); i++) { idTab[i] = mId.get(i); } // ΠΏΠΎΠ·ΠΈΡΠΈΡ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° final int idvadaptere = position; // Π²ΡΠ²ΠΎΠ΄ΠΈΠΌ Π½Π° ΡΠΊΡΠ°Π½ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΈ, Π² RecyclerView holder.mTextView.setText(mDataset.get(position)); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Context context = v.getContext(); Intent ddddd = new Intent(context, LastActivity.class); ddddd.putExtra("id", idTab[idvadaptere]); context.startActivity(ddddd); } }); } In the second Activity LastActivity, I get the id and, based on this id, I am already outputting the values ββinto text fields
// ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ Intent ΠΈΠ·Π²Π»ΠΈΠΊΠ°Π΅ΠΌ ΠΈΠ· Π½Π΅Π³ΠΎ ΠΎΠ±ΡΠ΅ΠΊΡ Intent intent = getIntent(); // ΠΈΠ·Π²Π»Π΅ΠΊΠ°Π΅ΠΌ ΠΈΠ· Π½Π΅Π³ΠΎ ΠΎΠ±ΡΠ΅ΠΊΡ idString = intent.getStringExtra("id"); // ΠΊΠΎΠ½Π²Π΅ΡΡΠΈΡΡΠ΅ΠΌ id Π² ΡΠΈΡΠ»ΠΎ idInt = Integer.parseInt(idString); // Π²ΡΠ²ΠΎΠ΄ΠΈΠΌ ΡΠ΅ΠΊΡΡΠΎΠ²ΡΠ΅ ΠΏΠΎΠ»Ρ Contact title = Contact.findById(Contact.class, idInt); String titleStr = title.title; textView.setText(titleStr); Contact prich = Contact.findById(Contact.class, idInt); String prichStr = prich.prich; textView2.setText(prichStr); The problem is that if you enter a title in the search, then in the list the position of this title will no longer be the fifth one, for example, but the first and id will already be different, in the second one you will substitute the values ββnot from the fifth id but from the first
Search source, it works fine, if anyone needs to copy, the only problem is data transfer when you click on the list item
activity_main.xml
<android.support.v7.widget.Toolbar ...>
<android.support.v7.widget.SearchView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/search_view" android:layout_gravity="right" app:theme="@style/Theme.AppCompat.NoActionBar" app:searchIcon="@drawable/ic_search_white_24dp"/> MainActivity.java
private SearchView searchView; in onCreate
searchView = (SearchView) findViewById(R.id.search_view); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String text) { return false; } @Override public boolean onQueryTextChange(String text) { mAdapter.filter(text); return false; } }); RecyclerAdapter.java
// headers
private ArrayList<String> mDataset; private ArrayList<String> mCleanCopyDataset; Constructor
// ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ public RecyclerAdapter(ArrayList<String> dataset) { mDataset = dataset; mCleanCopyDataset = mDataset; } Search
// Π ΠΌΠ΅ΡΠΎΠ΄Π΅ filter() ΠΌΡ ΠΏΠ΅ΡΠ΅Π±ΠΈΡΠ°Π΅ΠΌ Π²ΡΠ΅ ΠΏΡΠ½ΠΊΡΡ ΡΠΏΠΈΡΠΊΠ° ΠΈ, Π΅ΡΠ»ΠΈ ΠΊΠ°ΠΊΠΎΠΉ-ΡΠΎ ΠΏΡΠ½ΠΊΡ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ ΠΈΡΠΊΠΎΠΌΡΠΉ ΡΠ΅ΠΊΡΡ, ΡΠΎ ΠΌΡ Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ Π΅Π³ΠΎ Π² Π½ΠΎΠ²ΡΠΉ ΡΠΏΠΈΡΠΎΠΊ mDataset: public void filter(String charText) { charText = charText.toLowerCase(Locale.getDefault()); mDataset = new ArrayList<String>(); if (charText.length() == 0) { // mCleanCopyDataset Ρ Π½Π°Ρ Π²ΡΠ΅Π³Π΄Π° ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ Π½Π΅ΠΈΠ·ΠΌΠ΅Π½Π΅Π½Π½ΡΡ ΠΈ Π½Π΅ΠΎΡΡΠΈΠ»ΡΡΡΠΎΠ²Π°Π½Π½ΡΡ (ΠΏΠΎΠ»Π½ΡΡ) ΠΊΠΎΠΏΠΈΡ Π΄Π°Π½Π½ΡΡ
ΡΠΏΠΈΡΠΊΠ° mDataset.addAll(mCleanCopyDataset); } else { for (String item : mCleanCopyDataset) { // ΠΌΡ ΠΏΠ΅ΡΠ΅Π±ΠΈΡΠ°Π΅ΠΌ Π²ΡΠ΅ ΠΏΡΠ½ΠΊΡΡ ΡΠΏΠΈΡΠΊΠ° ΠΈ Π΅ΡΠ»ΠΈ ΠΊΠ°ΠΊΠΎΠΉ-ΡΠΎ ΠΏΡΠ½ΠΊΡ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ ΠΈΡΠΊΠΎΠΌΡΠΉ ΡΠ΅ΠΊΡΡ, ΡΠΎ ΠΌΡ Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ Π΅Π³ΠΎ Π² Π½ΠΎΠ²ΡΠΉ ΡΠΏΠΈΡΠΎΠΊ mDataset if (item.toLowerCase(Locale.getDefault()).contains(charText)) { mDataset.add(item); } } } // ΠΌΠ΅ΡΠΎΠ΄ notifyDataSetChanged() ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΠΎΠ±Π½ΠΎΠ²ΠΈΡΡ ΡΠΏΠΈΡΠΎΠΊ Π½Π° ΡΠΊΡΠ°Π½Π΅ ΠΏΠΎΡΠ»Π΅ ΡΠΈΠ»ΡΡΡΠ°ΡΠΈΠΈ notifyDataSetChanged(); } 

ddddd.putExtra("id", idTab[idvadaptere]);onddddd.putExtra("id", idTab[holder.getAdapterPosition()]);- Yura Ivanov