JOHN JOHNNNY

JOHN JOHNNNY

  • NA
  • 190
  • 140k

Populate search view in android from text files

May 19 2015 5:17 AM
I am trying to populate search and listview from text file and
am having issues with this code can someone please help me
This is the error message in the log cat
" java.lang.NullPointerException at searchviewsqlite.MyActivity.onCreateOptionsMenu"
This is the code below
 
 
public class MyActivity extends ActionBarActivity {       Menu m;       final Context context=this;       @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_my);           DatabaseTable db=new DatabaseTable(this);     }       @Override     public boolean onCreateOptionsMenu(Menu menu) {         MenuInflater inflater = getMenuInflater();           inflater.inflate(R.menu.options_menu, menu);            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {               SearchManager searchManager =(SearchManager) getSystemService(Context.SEARCH_SERVICE);               SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();               searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));//Error here          }         return true;       }       @Override     public boolean onOptionsItemSelected(MenuItem item) {         //return super.onOptionsItemSelected(item);          switch (item.getItemId()) {             case R.id.search:                 onSearchRequested();                 return true;               default:                   return false;         }     } }