use of com.actionbarsherlock.widget.SearchView in project howabout-android by recomio.
the class MainActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.main, menu);
// Place an action bar item for searching.
final SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
searchView.setQueryHint("Search");
searchView.setIconified(true);
searchMenu = menu.getItem(0);
searchMenu.setActionView(searchView).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean queryTextFocused) {
if (!queryTextFocused) {
Log.d("searchMenu.collapseActionView();", Boolean.toString(searchMenu.collapseActionView()));
searchView.setQuery("", false);
}
}
});
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String searchKeyword) {
Intent intent = new Intent(MainActivity.this, SearchedTrackListActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle bundle = new Bundle();
bundle.putString("category", "music");
bundle.putString("method", "search");
bundle.putString("searchKeyword", searchKeyword);
intent.putExtras(bundle);
startActivity(intent);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return true;
}
});
return super.onCreateOptionsMenu(menu);
}
use of com.actionbarsherlock.widget.SearchView in project ActionBarSherlock by JakeWharton.
the class Issue659 method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.issue659, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
return true;
}
use of com.actionbarsherlock.widget.SearchView in project base-adapter-helper by JoanZapata.
the class TwitterFragment method onSearch.
@OptionsItem(R.id.search)
protected void onSearch(final MenuItem item) {
this.searchMenuItem = item;
SearchView searchView = (SearchView) item.getActionView();
searchView.setQueryHint(followingAccount);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
item.collapseActionView();
onSearchSubmit(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return true;
}
});
}
use of com.actionbarsherlock.widget.SearchView in project little-bear-dictionary by daimajia.
the class GeneralActivity method onKeyDown.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
SearchView searchView = null;
switch(keyCode) {
case KeyEvent.KEYCODE_SEARCH:
if (mSlidingMenu.isMenuShowing()) {
mSlidingMenu.toggle();
}
if (mCurrentShowID != R.id.search) {
removerCurrentAndReplaceFragment(R.id.search, new QueryWordFragment(), false);
}
searchView = (SearchView) findViewById(android.R.id.inputArea);
if (searchView != null)
searchView.setIconified(false);
return true;
case KeyEvent.KEYCODE_MENU:
mSlidingMenu.toggle();
break;
case KeyEvent.KEYCODE_BACK:
if (mSlidingMenu.isMenuShowing()) {
mSlidingMenu.toggle();
return true;
}
searchView = (SearchView) findViewById(android.R.id.inputArea);
if (searchView != null && searchView.isIconified() == false) {
searchView.clearFocus();
searchView.setIconified(true);
return true;
}
boolean askQuite = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean("quitetip", true);
if (askQuite == true) {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(R.string.tips);
builder.setMessage(R.string.quite_tips);
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
builder.setNeutralButton(R.string.give_suggestion, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
UMFeedbackService.openUmengFeedbackSDK(GeneralActivity.this);
}
});
builder.setNegativeButton(R.string.cancel, null);
builder.show();
}
break;
default:
}
return super.onKeyDown(keyCode, event);
}
use of com.actionbarsherlock.widget.SearchView in project ActionBarSherlock by JakeWharton.
the class SearchViews method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//Used to put dark icons on light action bar
boolean isLight = SampleList.THEME == R.style.Theme_Sherlock_Light;
//Create the search view
SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
searchView.setQueryHint("Search for countries…");
searchView.setOnQueryTextListener(this);
searchView.setOnSuggestionListener(this);
if (mSuggestionsAdapter == null) {
MatrixCursor cursor = new MatrixCursor(COLUMNS);
cursor.addRow(new String[] { "1", "'Murica" });
cursor.addRow(new String[] { "2", "Canada" });
cursor.addRow(new String[] { "3", "Denmark" });
mSuggestionsAdapter = new SuggestionsAdapter(getSupportActionBar().getThemedContext(), cursor);
}
searchView.setSuggestionsAdapter(mSuggestionsAdapter);
menu.add("Search").setIcon(isLight ? R.drawable.ic_search_inverse : R.drawable.abs__ic_search).setActionView(searchView).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
return true;
}
Aggregations