I am making a music player application on android. My Launcher Activity(MainActivity.java)
displays all the songs in a Custom ListView
. My app was running perfectly and then I decided to add a SearchView
widget in the ToolBar
.
Now when I type a query in the SearchView
, me Searchable.java
activity opens up and after 2-3 sconds the whole screen turns black. The search results are shown for a brief time but the black screen stays there permanently.
If don't use the search option then the application shows no such behavior.
Your app displaying black screen because you are doing search operations on your main thread , that's why your main thread hanging , check your log monitor you will get error like , too much work on main thread , for overcome this issue you need to perform your search operations on another thread or in background and update your view when search completed , you can use Asynctask for background task .