Search in sources :

Example 1 with UpdatePolicy

use of de.bahnhoefe.deutschlands.bahnhofsfotos.model.UpdatePolicy in project RSAndroidApp by RailwayStations.

the class MainActivity method onCreateOptionsMenu.

@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    final SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    final MenuItem searchMenu = menu.findItem(R.id.search);
    final SearchView search = (SearchView) searchMenu.getActionView();
    search.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
    search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(final String s) {
            Log.d(TAG, "onQueryTextSubmit: " + s);
            searchString = s;
            updateStationList();
            return false;
        }

        @Override
        public boolean onQueryTextChange(final String s) {
            Log.d(TAG, "onQueryTextChange: " + s);
            searchString = s;
            updateStationList();
            return false;
        }
    });
    final UpdatePolicy updatePolicy = baseApplication.getUpdatePolicy();
    menu.findItem(updatePolicy.getId()).setChecked(true);
    return true;
}
Also used : UpdatePolicy(de.bahnhoefe.deutschlands.bahnhofsfotos.model.UpdatePolicy) SearchView(androidx.appcompat.widget.SearchView) SearchManager(android.app.SearchManager) MenuItem(android.view.MenuItem) TargetApi(android.annotation.TargetApi)

Aggregations

TargetApi (android.annotation.TargetApi)1 SearchManager (android.app.SearchManager)1 MenuItem (android.view.MenuItem)1 SearchView (androidx.appcompat.widget.SearchView)1 UpdatePolicy (de.bahnhoefe.deutschlands.bahnhofsfotos.model.UpdatePolicy)1