0

So this I the code I use in the Activity that should get a search function:

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.options_menu, menu);

        // Associate searchable configuration with the SearchView
        SearchManager searchManager =
                (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView =
                (SearchView) menu.findItem(R.id.search).getActionView();
        ***searchView.setSearchableInfo(
                searchManager.getSearchableInfo(getComponentName()));***


        return true;
    }

I got this code from the androidDeveloper site. The two lines that I made highlighted are the ones that are making trouble. What am I doing wrong?

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

1

I found the solution in the first answer of this post, just in case someone else has the same problem! Android - NullPointerException on SearchView in Action Bar

Community
  • 1
  • 1