title: Put a SearchView on the ActionBar
body: <p>Layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
   &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="wrap_content"
  android:layout_height="match_parent"
  android:id="@+id/llist"
  tools:context="com.android.parteek.contentprovider.Main2Activity"&gt;
  
  &lt;android.support.v7.widget.SearchView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:id="@+id/serch"&gt;
  &lt;/android.support.v7.widget.SearchView&gt;
  
  &lt;ListView
      android:id="@+id/list"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.android.parteek.contentprovider.Main2Activity"&gt;
  
  &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Code</p>
  
  <pre><code>package com.android.parteek.contentprovider;
  
  import android.content.ContentResolver;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.database.Cursor;
  import android.support.v7.app.AlertDialog;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.support.v7.widget.SearchView;
  import android.util.Log;
  import android.view.Menu;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ListView;
  import android.widget.Toast;
  
  import java.util.ArrayList;
  
  public class Main2Activity extends AppCompatActivity implements AdapterView.OnItemLongClickListener, SearchView.OnQueryTextListener {
  ListView l;
  ArrayList&lt;Bean&gt; arrayList;
  UserAdapterr userAdapterr;
  ContentResolver contentResolver;
  SearchView searchView;
  Bean b,b1;
  int pos;
  void views(){
      l=(ListView)findViewById(R.id.list);
      searchView=(SearchView)findViewById(R.id.serch);
  
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main2);
      views();
      contentResolver=getContentResolver();
      retrieve();
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.searchmenu,menu);
      searchView=(SearchView)menu.findItem(R.id.search).getActionView();
     searchView.setIconifiedByDefault(true);
     searchView.setOnQueryTextListener(this);
     searchView.setQueryHint("search.....");
  
      return super.onCreateOptionsMenu(menu);
  }
  
  
  @Override
  public boolean onQueryTextSubmit(String query) {
      return false;
  }
  
  @Override
  public boolean onQueryTextChange(String newText) {
      return false;
  }
  }
  </code></pre>
  
  <p>Error</p>
  
  <pre><code> java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.SearchView.setIconifiedByDefault(boolean)' on a null object reference
                                                                                           at com.android.parteek.contentprovider.Main2Activity.onCreateOptionsMenu(Main2Activity.java:147)
  </code></pre>