List of usage examples for android.view KeyEvent ACTION_DOWN
int ACTION_DOWN
To view the source code for android.view KeyEvent ACTION_DOWN.
Click Source Link
From source file:com.example.photoremark.MainActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { onExit();//w w w . jav a 2s . c om } } return true; }
From source file:com.phonegap.plugin.ChildBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject /* ww w. j ava 2 s.com*/ */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", true); } // Create dialog in new thread Runnable runnable = new Runnable() { public void run() { dialog = new Dialog(ctx.getContext(), android.R.style.Theme_Translucent_NoTitleBar); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); LinearLayout.LayoutParams backParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams forwardParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1.0f); LinearLayout.LayoutParams closeParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams wvParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); LinearLayout main = new LinearLayout(ctx.getContext()); main.setOrientation(LinearLayout.VERTICAL); LinearLayout toolbar = new LinearLayout(ctx.getContext()); toolbar.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); toolbar.setOrientation(LinearLayout.HORIZONTAL); ImageButton back = new ImageButton(ctx.getContext()); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); back.setId(1); try { back.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setLayoutParams(backParams); ImageButton forward = new ImageButton(ctx.getContext()); forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); forward.setId(2); try { forward.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setLayoutParams(forwardParams); edittext = new EditText(ctx.getContext()); edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); edittext.setId(3); edittext.setSingleLine(true); edittext.setText(url); edittext.setLayoutParams(editParams); ImageButton close = new ImageButton(ctx.getContext()); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); close.setId(4); try { close.setImageBitmap(loadDrawable("www/childbrowser/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setLayoutParams(closeParams); webview = new WebView(ctx.getContext()); webview.setWebChromeClient(new WebChromeClient()); WebViewClient client = new ChildBrowserClient(edittext); webview.setWebViewClient(client); WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginsEnabled(true); settings.setDomStorageEnabled(true); webview.loadUrl(url); webview.setId(5); webview.setInitialScale(0); webview.setLayoutParams(wvParams); webview.requestFocus(); webview.requestFocusFromTouch(); toolbar.addView(back); toolbar.addView(forward); toolbar.addView(edittext); toolbar.addView(close); if (getShowLocationBar()) { main.addView(toolbar); } main.addView(webview); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = ctx.getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.ctx.runOnUiThread(runnable); return ""; }
From source file:com.taobao.wuzhong.plugins.ChildBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject// w w w. j av a 2 s .c o m */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", true); } // Create dialog in new thread Runnable runnable = new Runnable() { public void run() { dialog = new Dialog(ctx.getContext(), android.R.style.Theme_Translucent_NoTitleBar); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); LinearLayout.LayoutParams backParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams forwardParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1.0f); LinearLayout.LayoutParams closeParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams wvParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); LinearLayout main = new LinearLayout(ctx.getContext()); main.setOrientation(LinearLayout.VERTICAL); LinearLayout toolbar = new LinearLayout(ctx.getContext()); toolbar.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); toolbar.setOrientation(LinearLayout.HORIZONTAL); ImageButton back = new ImageButton(ctx.getContext()); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); back.setId(1); try { back.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setLayoutParams(backParams); ImageButton forward = new ImageButton(ctx.getContext()); forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); forward.setId(2); try { forward.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setLayoutParams(forwardParams); edittext = new EditText(ctx.getContext()); edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); edittext.setId(3); edittext.setSingleLine(true); edittext.setText(url); edittext.setLayoutParams(editParams); ImageButton close = new ImageButton(ctx.getContext()); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); close.setId(4); try { close.setImageBitmap(loadDrawable("www/childbrowser/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setLayoutParams(closeParams); webview = new WebView(ctx.getContext()); webview.setWebChromeClient(new WebChromeClient()); WebViewClient client = new ChildBrowserClient(edittext); webview.setWebViewClient(client); WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginsEnabled(true); settings.setDomStorageEnabled(true); webview.loadUrl(url); webview.setId(5); webview.setInitialScale(0); webview.setLayoutParams(wvParams); webview.requestFocus(); webview.requestFocusFromTouch(); toolbar.addView(back); toolbar.addView(forward); toolbar.addView(edittext); toolbar.addView(close); if (getShowLocationBar()) { main.addView(toolbar); } main.addView(webview); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = ctx.getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.ctx.runOnUiThread(runnable); return ""; }
From source file:com.scooter1556.sms.android.fragment.tv.TvVideoPlayerFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { view.setOnKeyListener(new View.OnKeyListener() { @Override//from w w w . jav a 2s.co m public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { if (playbackState == PlaybackStateCompat.STATE_PLAYING) { pause(); } else { play(currentMedia); } return true; } } return false; } }); }
From source file:cn.zhangls.android.weibo.ui.edit.EditActivity.java
/** * ?/*from w w w . ja v a2 s. c om*/ */ private void setText(String text, boolean isComment) { if (isComment) { mBinding.acEditText.setText(TextUtil.convertText(this, text, ContextCompat.getColor(this, R.color.colorAccent), (int) mBinding.acEditText.getTextSize())); return; } if (mStatus.getRetweeted_status() != null) // ? mBinding.acEditText.setText(TextUtil.convertText(this, text, ContextCompat.getColor(this, R.color.colorAccent), (int) mBinding.acEditText.getTextSize())); // ??????? mTopicList = TextUtil.findRegexString(mBinding.acEditText.getText().toString(), Constants.RegularExpression.TopicRegex); mNameList = TextUtil.findRegexString(mBinding.acEditText.getText().toString(), Constants.RegularExpression.NameRegex); // ? UserName Topic mBinding.acEditText.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // return keyCode == KeyEvent.KEYCODE_DEL && event.getAction() == KeyEvent.ACTION_DOWN && (setSelection(mBinding.acEditText, mTopicList, true) || setSelection(mBinding.acEditText, mNameList, true)); } }); // EditText ? UserName Topic ? UserName Topic ? mBinding.acEditText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // ? Topic Name boolean topic = setSelection(mBinding.acEditText, mTopicList, false); if (!topic) { setSelection(mBinding.acEditText, mNameList, false); } } }); }
From source file:com.example.castsample.CastSampleActivity.java
/** * Processes volume up and volume down actions upon receiving them as key events. *//* ww w .j a v a 2 s . com*/ @Override public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) { double currentVolume; if (mMessageStream != null) { currentVolume = mMessageStream.getVolume(); logVIfEnabled(TAG, "Volume up from " + currentVolume); if (currentVolume < 1.0) { logVIfEnabled(TAG, "New volume: " + (currentVolume + VOLUME_INCREMENT)); onSetVolume(currentVolume + VOLUME_INCREMENT); } } else { Log.e(TAG, "dispatchKeyEvent - volume up - mMPMS==null"); } } return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { double currentVolume; if (mMessageStream != null) { currentVolume = mMessageStream.getVolume(); logVIfEnabled(TAG, "Volume down from: " + currentVolume); if (currentVolume > 0.0) { logVIfEnabled(TAG, "New volume: " + (currentVolume - VOLUME_INCREMENT)); onSetVolume(currentVolume - VOLUME_INCREMENT); } } else { Log.e(TAG, "dispatchKeyEvent - volume down - mMPMS==null"); } } return true; default: return super.dispatchKeyEvent(event); } }
From source file:com.vuze.android.remote.fragment.FilesFragment.java
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, Bundle savedInstanceState) {/* w w w . jav a 2 s . com*/ if (AndroidUtils.DEBUG) { Log.d(TAG, "onCreateview " + this); } View view = inflater.inflate(R.layout.frag_torrent_files, container, false); FragmentActivity activity = getActivity(); progressBar = (ProgressBar) activity.findViewById(R.id.details_progress_bar); viewAreaToggleEditMode = view.findViewById(R.id.files_area_toggleditmode); tvScrollTitle = (TextView) view.findViewById(R.id.files_scrolltitle); btnEditMode = (CompoundButton) view.findViewById(R.id.files_editmode); if (btnEditMode != null) { btnEditMode.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (adapter == null) { return; } adapter.setInEditMode(btnEditMode.isChecked()); } }); } final SwipeRefreshLayoutExtra swipeRefresh = (SwipeRefreshLayoutExtra) view .findViewById(R.id.swipe_container); if (swipeRefresh != null) { swipeRefresh.setExtraLayout(R.layout.swipe_layout_extra); swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { if (sessionInfo == null) { return; } showProgressBar(); sessionInfo.executeRpc(new RpcExecuter() { @Override public void executeRpc(TransmissionRPC rpc) { rpc.getTorrentFileInfo(TAG, torrentID, null, new TorrentListReceivedListener() { @Override public void rpcTorrentListReceived(String callID, List<?> addedTorrentMaps, List<?> removedTorrentIDs) { AndroidUtils.runOnUIThread(FilesFragment.this, new Runnable() { @Override public void run() { swipeRefresh.setRefreshing(false); } }); } }); } }); } }); swipeRefresh.setOnExtraViewVisibilityChange(this); } listview = (RecyclerView) view.findViewById(R.id.files_list); listview.setLayoutManager(new PreCachingLayoutManager(getContext())); listview.setAdapter(adapter); listview.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { { if (event.getAction() != KeyEvent.ACTION_DOWN) { return false; } switch (keyCode) { case KeyEvent.KEYCODE_DPAD_RIGHT: { // expand int i = adapter.getSelectedPosition(); FilesAdapterDisplayObject item = adapter.getItem(i); if (item instanceof FilesAdapterDisplayFolder) { if (!((FilesAdapterDisplayFolder) item).expand) { ((FilesAdapterDisplayFolder) item).expand = true; adapter.getFilter().filter(""); return true; } } break; } case KeyEvent.KEYCODE_DPAD_LEFT: { // collapse int i = adapter.getSelectedPosition(); FilesAdapterDisplayObject item = adapter.getItem(i); if (item instanceof FilesAdapterDisplayFolder) { if (((FilesAdapterDisplayFolder) item).expand) { ((FilesAdapterDisplayFolder) item).expand = false; adapter.getFilter().filter(""); return true; } } break; } case KeyEvent.KEYCODE_MEDIA_PLAY: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: { launchOrStreamFile(); return true; } } return false; } } }); listview.setOnScrollListener(new RecyclerView.OnScrollListener() { int firstVisibleItem = 0; @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); LinearLayoutManager lm = (LinearLayoutManager) listview.getLayoutManager(); int firstVisibleItem = lm.findFirstCompletelyVisibleItemPosition(); if (firstVisibleItem != this.firstVisibleItem) { this.firstVisibleItem = firstVisibleItem; FilesAdapterDisplayObject itemAtPosition = adapter.getItem(firstVisibleItem); // Log.d(TAG, "itemAt" + firstVisibleItem + " is " + itemAtPosition); // Log.d(TAG, "tvScrollTitle=" + tvScrollTitle); // Log.d(TAG, "viewAreaToggleEditMode=" + viewAreaToggleEditMode); if (itemAtPosition == null) { return; } if (itemAtPosition.parent != null) { if (viewAreaToggleEditMode != null) { viewAreaToggleEditMode.setVisibility(View.GONE); } if (tvScrollTitle != null) { tvScrollTitle.setVisibility(View.VISIBLE); tvScrollTitle.setText(itemAtPosition.parent.folder); } } else { if (viewAreaToggleEditMode != null) { viewAreaToggleEditMode.setVisibility(View.VISIBLE); } if (tvScrollTitle != null) { if (viewAreaToggleEditMode != null) { tvScrollTitle.setVisibility(View.INVISIBLE); } tvScrollTitle.setText(""); } } } } }); FlexibleRecyclerSelectionListener rs = new FlexibleRecyclerSelectionListener<FilesTreeAdapter, FilesAdapterDisplayObject>() { @Override public void onItemSelected(FilesTreeAdapter adapter, final int position, boolean isChecked) { } @Override public void onItemClick(FilesTreeAdapter adapter, int position) { if (AndroidUtils.usesNavigationControl()) { FilesAdapterDisplayObject oItem = adapter.getItem(position); if (adapter.isInEditMode()) { adapter.flipWant(oItem); return; } if (oItem instanceof FilesAdapterDisplayFolder) { FilesAdapterDisplayFolder oFolder = (FilesAdapterDisplayFolder) oItem; oFolder.expand = !oFolder.expand; adapter.getFilter().filter(""); } else { showFileContextMenu(); } } } @Override public boolean onItemLongClick(FilesTreeAdapter adapter, int position) { if (AndroidUtils.usesNavigationControl()) { if (showFileContextMenu()) { return true; } } return false; } @Override public void onItemCheckedChanged(FilesTreeAdapter adapter, FilesAdapterDisplayObject item, boolean isChecked) { if (adapter.getCheckedItemCount() == 0) { finishActionMode(); } else { // Update the subtitle with file name showContextualActions(); } AndroidUtils.invalidateOptionsMenuHC(getActivity(), mActionMode); } }; adapter = new FilesTreeAdapter(this.getActivity(), rs); adapter.setSessionInfo(sessionInfo); adapter.setMultiCheckModeAllowed(false); adapter.setCheckOnSelectedAfterMS(100); listview.setAdapter(adapter); return view; }
From source file:androidx.media.session.MediaButtonReceiver.java
/** * Creates a broadcast pending intent that will send a media button event. The {@code action} * will be translated to the appropriate {@link KeyEvent}, and sent to the provided media * button receiver via the pending intent. The {@code action} should be one of the following: * <ul>/* w w w. j a v a2 s. c o m*/ * <li>{@link PlaybackStateCompat#ACTION_PLAY}</li> * <li>{@link PlaybackStateCompat#ACTION_PAUSE}</li> * <li>{@link PlaybackStateCompat#ACTION_SKIP_TO_NEXT}</li> * <li>{@link PlaybackStateCompat#ACTION_SKIP_TO_PREVIOUS}</li> * <li>{@link PlaybackStateCompat#ACTION_STOP}</li> * <li>{@link PlaybackStateCompat#ACTION_FAST_FORWARD}</li> * <li>{@link PlaybackStateCompat#ACTION_REWIND}</li> * <li>{@link PlaybackStateCompat#ACTION_PLAY_PAUSE}</li> * </ul> * * @param context The context of the application. * @param mbrComponent The full component name of a media button receiver where you want to send * this intent. * @param action The action to be sent via the pending intent. * @return Created pending intent, or null if the given component name is null or the * {@code action} is unsupported/invalid. */ public static PendingIntent buildMediaButtonPendingIntent(Context context, ComponentName mbrComponent, @MediaKeyAction long action) { if (mbrComponent == null) { Log.w(TAG, "The component name of media button receiver should be provided."); return null; } int keyCode = PlaybackStateCompat.toKeyCode(action); if (keyCode == KeyEvent.KEYCODE_UNKNOWN) { Log.w(TAG, "Cannot build a media button pending intent with the given action: " + action); return null; } Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON); intent.setComponent(mbrComponent); intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, keyCode)); return PendingIntent.getBroadcast(context, keyCode, intent, 0); }
From source file:org.connectbot.TerminalView.java
@Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) { outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_FLAG_NO_ENTER_ACTION | EditorInfo.IME_ACTION_NONE; outAttrs.inputType = EditorInfo.TYPE_NULL; return new BaseInputConnection(this, false) { @Override/*w ww . j a v a 2s .co m*/ public boolean deleteSurroundingText(int leftLength, int rightLength) { if (rightLength == 0 && leftLength == 0) { return this.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); } for (int i = 0; i < leftLength; i++) { this.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); } // TODO: forward delete return true; } }; }
From source file:io.syng.activity.BaseActivity.java
private void initSearch() { mSearchTextView.addTextChangedListener(new TextWatcher() { @Override/*from www .ja v a2 s .co m*/ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { String searchValue = editable.toString(); updateDAppList(searchValue); } }); mSearchTextView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View view, int i, KeyEvent keyEvent) { if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) { GeneralUtil.hideKeyBoard(mSearchTextView, BaseActivity.this); return true; } return false; } }); }