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();
}
}
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;
}
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);
}
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();
}
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;
}
Aggregations