Questions tagged [android-search]

Search is a core user feature on Android. Users should be able to search any data that is available to them, whether the content is located on the device or the Internet. To help create a consistent search experience for users, Android provides a search framework that helps you implement search for your application.

The search framework offers two modes of search input: a search dialog at the top of the screen or a search widget (SearchView) that you can embed in your activity layout. In either case, the Android system will assist your search implementation by delivering search queries to a specific activity that performs searchs. You can also enable either the search dialog or widget to provide search suggestions as the user types. Figure 1 shows an example of the search dialog with optional search suggestions.

Once you've set up either the search dialog or the search widget, you can:

  • Enable voice search
  • Provide search suggestions based on recent user queries
  • Provide custom search suggestions that match actual results in your application data
  • Offer your application's search suggestions in the system-wide Quick Search Box

The following documents show you how to use Android's framework to implement search:

Creating a Search Interface:

How to set up your application to use the search dialog or search widget.

Adding Recent Query Suggestions:

How to provide suggestions based on queries previously used.

Adding Custom Suggestions:

How to provide suggestions based on custom data from your application and also offer them in the system-wide Quick Search Box.

Searchable Configuration:

A reference document for the searchable configuration file (though the other documents also discuss the configuration file in terms of specific behaviors).

413 questions
2
votes
1 answer

auto open searchin action bar only shows keyboard

I am trying to have the search bar in the actionbar auto open when my search page is launched. I use this to attempt to open the search bar automatically on page open: @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate…
Mike
  • 6,751
  • 23
  • 75
  • 132
2
votes
2 answers

Android SearchView filtered listview - how to remove query box?

I have added a SearchView to an ActionBar which filters a ListView. Everything works fine, the only problem is when I write a query in the SearchView, the query text also appears in a box in the middle of the screen in big fonts. I guess it is some…
Ran
  • 4,117
  • 4
  • 44
  • 70
1
vote
1 answer

How to add two trailing icons on Material3 Search Bar on Android?

I want to add two trailing icons (one of them being the 3 dots menu icon) on my Material 3 Search Bar. Examples: Source: GitHub and this: Source: Material 3 But I can't find any way to do this nor any documentation anywhere in Google's repos or…
tzegian
  • 394
  • 3
  • 13
1
vote
0 answers

Tell me how to save the search history?

I'm trying to save and display the search history. To do this, I use the latest version of the library, the search history is displayed until I exit the application.'com.github.mancj:MaterialSearchBar:0.8.5' MainActivity public class MainActivity…
Eypro Corp
  • 11
  • 3
1
vote
0 answers

Search doesn't work as expected after selecting an item from the BottomSheetDialogFragment and then select the bottomNavigation menu

I have an awkward situation for which I have been trying to find the reason and fix it for two days and I failed. Let me explain it first. On launching the app recyclerView in the 'HomeFragment' is filled with data that fetched from Firestore. I…
1
vote
1 answer

Android SearchView only briefly displays cursor when I click on search input field, and no keyboard displays. Can't input text

I'm trying to implement a SearchView inside of a layout, not in a menu layout, but when I click on the search input box, the cursor just briefly shows, then disappears, and the keyboard never displays. It seems like its loosing focus possibly? I've…
1
vote
1 answer

Recyclerview + Search filter: Can not delete items from recyclerview and wrong behavior in adapter

I have a program that I am writing to be able to view the files on the device in the app folder via a recyclerview, and delete them. The mainactivity handles the file deleting and removal, and the adapter handles finding postition and visual changes…
1
vote
1 answer

How to search a diffutil filter out results from existing list

I'm using DiffUtil in my RecyclerView to displays a list from a database using the Room component. I would like to add a search function in the Appbar, that will filter out the existing items in the list as the user is typing. My app currently has a…
Shawn
  • 1,222
  • 1
  • 18
  • 41
1
vote
1 answer

Empty dataset indicator for RecyclerView not showing

I'm trying to show a Snackbar with a message whenever the dataset of a filtered RecyclerView contains 0 items but for some reason, the Snackbar doesn't appear at all. Does the relevant code need to go in the Fragment or Adapter? Can this be donw…
wbk727
  • 8,017
  • 12
  • 61
  • 125
1
vote
1 answer

How to implement Search Filter with RecyclerView

I followed some youtube tutorial about SQLite and RecyclerView (https://www.youtube.com/watch?v=VQKq9RHMS_0&ab_channel=Stevdza-San) I completed all the things and customize it as I need to my app and everything work fine. Now all I want to do is add…
1
vote
1 answer

How to get the total query count with a PagedListAdapter in Android Room

This follows a logic from a previous question, quoting the relevant code portion here: I have the following query implemented and it can return any amount of results between 0 up to the number of entries in the database, depends on the query input…
Shadow
  • 4,168
  • 5
  • 41
  • 72
1
vote
1 answer

The Search View is not giving any result in my Fragment containing RecyclerView. After I click on the Search icon the screen is just blank

I have a fragment with RecyclerView and Room Database and I want to add a search view. I have successfully added the search icon and also added the code in the Fragment as well as Adapter. But the problem is that when I click on the Search icon, the…
1
vote
0 answers

Search in Fragments that hold Recyclerview

I have 3 Fragments and they all are holding a recyclerView. But I don't know how I should call adapter.getFilter().filter(newText); in onQueryTextChange. Any ideas? MainActivity: public class MainActivity extends AppCompatActivity { DatabaseHelper…
1
vote
0 answers

RecyclerView getting wrong position using onClick after searching

My RecyclerView is getting a filtered position after the list is filtered using the SearchView. This means that when the list item is clicked the information for the wrong item is displayed. I'm looking for a way to keep the original list position…
ebk
  • 11
  • 2
1
vote
1 answer

How to stop Incessant crash on search filter in Android recyclerview

I have been struggling to stop an index out of bounds exception crash every single time I do a search in a searchview. I tried a couple of things listed online : on search getting array out of index bound…
user11455292