Search in sources :

Example 66 with SearchView

use of android.support.v7.widget.SearchView in project Osmand by osmandapp.

the class FavoritesActivity method updateSearchView.

public static void updateSearchView(Activity activity, SearchView searchView) {
    // do not ever do like this
    OsmandApplication app = (OsmandApplication) activity.getApplication();
    if (!app.getSettings().isLightContent()) {
        return;
    }
    try {
        ImageView cancelIcon = (ImageView) searchView.findViewById(R.id.search_close_btn);
        cancelIcon.setImageResource(R.drawable.ic_action_gremove_dark);
        // styling search hint icon and text
        SearchView.SearchAutoComplete searchEdit = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);
        searchEdit.setTextColor(activity.getResources().getColor(R.color.color_white));
        SpannableStringBuilder stopHint = new SpannableStringBuilder("   ");
        Float rawTextSize = searchEdit.getTextSize();
        int textSize = (int) (rawTextSize * 1.25);
        // setting icon as spannable
        Drawable searchIcon = activity.getResources().getDrawable(R.drawable.ic_action_search_dark);
        searchIcon.setBounds(0, 0, textSize, textSize);
        stopHint.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        searchEdit.setHint(stopHint);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) SearchView(android.support.v7.widget.SearchView) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) SpannableStringBuilder(android.text.SpannableStringBuilder) ImageSpan(android.text.style.ImageSpan)

Example 67 with SearchView

use of android.support.v7.widget.SearchView in project nextcloud-notes by stefan-niedermann.

the class NotesListViewActivity method onCreateOptionsMenu.

/**
 * Adds the Menu Items to the Action Bar.
 *
 * @param menu Menu
 * @return boolean
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_list_view, menu);
    // Associate searchable configuration with the SearchView
    final MenuItem item = menu.findItem(R.id.search);
    searchView = (SearchView) MenuItemCompat.getActionView(item);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            refreshLists();
            return true;
        }
    });
    return true;
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 68 with SearchView

use of android.support.v7.widget.SearchView in project UdacityForum by collaborateudacity.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.option_menu, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchManager searchManager = (SearchManager) MainActivity.this.getSystemService(getApplicationContext().SEARCH_SERVICE);
    SearchView searchView = null;
    if (searchItem != null) {
        searchView = (SearchView) searchItem.getActionView();
    }
    if (searchView != null) {
        searchView.setSearchableInfo(searchManager.getSearchableInfo(MainActivity.this.getComponentName()));
    }
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) SearchManager(android.app.SearchManager) MenuItem(android.view.MenuItem)

Example 69 with SearchView

use of android.support.v7.widget.SearchView in project Roblu by wdavies973.

the class TBAEventSelector method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_apievent_select);
    teamNumber = new IO(getApplicationContext()).loadSettings().getTeamNumber();
    /*
         * Setup UI
         */
    // Setup
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Select an event");
    }
    // Progress bar
    bar = findViewById(R.id.progress_bar);
    bar.setVisibility(View.GONE);
    // Recycler view
    rv = findViewById(R.id.events_recycler);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setLayoutManager(linearLayoutManager);
    ((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
    // Setup the tbaEventAdapter
    tbaEventAdapter = new TBAEventAdapter(this, this);
    rv.setAdapter(tbaEventAdapter);
    // Setup the gesture listener
    ItemTouchHelper.Callback callback = new TutorialsRecyclerTouchHelper();
    ItemTouchHelper helper = new ItemTouchHelper(callback);
    helper.attachToRecyclerView(rv);
    /*
         * Create the "My Events / All Events" chooser
         */
    Spinner showTeam = findViewById(R.id.show_team);
    ArrayAdapter<String> sAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, new String[] { "My events", "All events" });
    sAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    showTeam.setAdapter(sAdapter);
    showTeam.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long l) {
            onlyShowMyEvents = parent.getItemAtPosition(position).toString().equals("My events");
            rv.setVisibility(View.INVISIBLE);
            bar.setVisibility(View.VISIBLE);
            if (tbaEventAdapter.getEvents() != null)
                tbaEventAdapter.getEvents().clear();
            tbaEventAdapter.notifyDataSetChanged();
            TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
            task.execute();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    // If no team number is found, default to "All events"
    if (new IO(getApplicationContext()).loadSettings().getTeamNumber() == 0)
        showTeam.setSelection(1);
    /*
         * Setup the years spinner
         */
    Spinner yearsSpinner = findViewById(R.id.spinner);
    selectedYear = Calendar.getInstance().get(Calendar.YEAR);
    String[] years = new String[selectedYear - 1991];
    for (int i = years.length - 1; i >= 0; i--) years[Math.abs(i - years.length + 1)] = String.valueOf(1992 + i);
    final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, years);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    yearsSpinner.setAdapter(adapter);
    yearsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            selectedYear = Integer.parseInt(adapterView.getItemAtPosition(i).toString());
            rv.setVisibility(View.INVISIBLE);
            bar.setVisibility(View.VISIBLE);
            if (tbaEventAdapter.getEvents() != null)
                tbaEventAdapter.getEvents().clear();
            tbaEventAdapter.notifyDataSetChanged();
            TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
            task.execute();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    /*
         * Setup the search view
         */
    searchView = findViewById(R.id.search_view);
    searchView.setHintTextColor(Color.BLACK);
    searchView.setHint("Search events");
    searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {

        @Override
        public void onSearchViewShown() {
        }

        @Override
        public void onSearchViewClosed() {
            TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
            task.setEvents(events);
            task.execute();
        }
    });
    searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            searchView.closeSearch();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            TBALoadEventsTask task = new TBALoadEventsTask(bar, rv, tbaEventAdapter, TBAEventSelector.this, teamNumber, selectedYear, onlyShowMyEvents);
            task.setEvents(events);
            task.setQuery(newText);
            task.execute();
            return true;
        }
    });
    // Sync UI with user preferences
    new UIHandler(this, toolbar).update();
}
Also used : TutorialsRecyclerTouchHelper(com.cpjd.roblu.ui.tutorials.TutorialsRecyclerTouchHelper) Spinner(android.widget.Spinner) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) TBALoadEventsTask(com.cpjd.roblu.tba.TBALoadEventsTask) Toolbar(android.support.v7.widget.Toolbar) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) UIHandler(com.cpjd.roblu.ui.UIHandler) IO(com.cpjd.roblu.io.IO) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 70 with SearchView

use of android.support.v7.widget.SearchView in project Android-NotesApp by HelloPraveenIO.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    mi = menu.findItem(R.id.menu_imp);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    search(searchView);
    EditText et = searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    et.setHint(MainActivity.this.getString(R.string.search));
    return true;
}
Also used : EditText(android.widget.EditText) SearchView(android.support.v7.widget.SearchView)

Aggregations

SearchView (android.support.v7.widget.SearchView)151 MenuItem (android.view.MenuItem)88 View (android.view.View)56 SearchManager (android.app.SearchManager)37 RecyclerView (android.support.v7.widget.RecyclerView)35 TextView (android.widget.TextView)26 MenuInflater (android.view.MenuInflater)24 ImageView (android.widget.ImageView)20 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)19 MenuItemCompat (android.support.v4.view.MenuItemCompat)18 Toolbar (android.support.v7.widget.Toolbar)16 SearchView (android.widget.SearchView)12 ArrayList (java.util.ArrayList)11 ViewGroup (android.view.ViewGroup)10 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)10 Intent (android.content.Intent)9 ListView (android.widget.ListView)9 BindView (butterknife.BindView)9 AdapterView (android.widget.AdapterView)8 EditText (android.widget.EditText)8