List of usage examples for android.view KeyEvent getKeyCode
public final int getKeyCode()
From source file:com.openerp.base.account.AccountFragment.java
@SuppressLint("DefaultLocale") @Override/*from w w w.ja v a 2s . c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true); this.context = getActivity(); // Inflate the layout for this fragment rootView = inflater.inflate(R.layout.fragment_account, container, false); scope = new AppScope(this); rootView.findViewById(R.id.edtServerURL).requestFocus(); getActivity().setTitle(R.string.title_setup_account); chkSecureConnection = (CheckBox) rootView.findViewById(R.id.chkIsSecureConnection); edtServerUrl = (EditText) rootView.findViewById(R.id.edtServerURL); chkSecureConnection.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { String serverUrl = edtServerUrl.getText().toString().toLowerCase(); if (chkSecureConnection.isChecked()) { serverUrl = serverUrl.replace("http://", ""); serverUrl = serverUrl.replace("https://", ""); serverUrl = "https://" + serverUrl; } else { serverUrl = serverUrl.replace("https://", ""); serverUrl = serverUrl.replace("http://", ""); } edtServerUrl.setText(serverUrl); edtServerUrl.setSelection(edtServerUrl.length()); } }); edtServerUrl.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) { goNext(); } return false; } }); return rootView; }
From source file:io.github.carlorodriguez.alarmon.MediaListView.java
public MediaListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setChoiceMode(CHOICE_MODE_SINGLE);/*from w w w. j a v a2s . c o m*/ setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (flipper == null || flipper.getDisplayedChild() == 0) { return false; } if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { if (event.getAction() == KeyEvent.ACTION_UP) { if (mPlayer != null) { mPlayer.stop(); } flipper.setInAnimation(getContext(), R.anim.slide_in_right); flipper.setOutAnimation(getContext(), R.anim.slide_out_right); flipper.showPrevious(); } return true; } return false; } }); }
From source file:org.yaawp.hmi.activities.CustomActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.i(TAG, "onKeyDown( KeyCode=" + keyCode + " KeyEvent=" + event.getAction()); boolean status = false; if (event.getAction() == KeyEvent.ACTION_DOWN) { if (event.getKeyCode() == lastKeyCode && event.getDownTime() - lastPressedTime < Const.DOUBLE_PRESS_HK_BACK_PERIOD) { status = onKeyTwiceDown(event.getKeyCode(), event); } else {/*w w w. ja va2s. c om*/ lastPressedTime = event.getDownTime(); lastKeyCode = event.getKeyCode(); status = onKeyOnceDown(keyCode, event); } } else { status = super.onKeyDown(keyCode, event); } return status; }
From source file:net.xisberto.work_schedule.alarm.AlarmMessageActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_MUTE: stopSound();//from w w w . j a v a 2s. c o m return true; default: return super.dispatchKeyEvent(event); } }
From source file:mobisocial.bento.todo.ui.TodoDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // extract UUID from intent mTodoUuid = getActivity().getIntent().getStringExtra(EXTRA_TODO_UUID); // View// w w w . ja va 2s . co m mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_todo_detail, container); mTitle = (EditText) mRootView.findViewById(R.id.todo_title); mDescription = (EditText) mRootView.findViewById(R.id.todo_description); mDescription.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { Log.d(TAG, "onEditorAction"); // clear focus v.clearFocus(); // close keyboard InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(mDescription.getWindowToken(), 0); return true; } return false; } }); mImageView = (ImageView) mRootView.findViewById(R.id.todo_image); // retrieve Todo data if (mTodoUuid != null) { mTodoItem = mManager.getTodoListItem(mTodoUuid); if (mTodoItem != null) { mTitle.setText(mTodoItem.title); mDescription.setText(mTodoItem.description); if (mTodoItem.hasImage) { mImageView.setImageBitmap(mManager.getTodoBitmap(mTodoItem.uuid, IMG_WIDTH, IMG_HEIGHT, 0)); mImageView.setVisibility(View.VISIBLE); } else { mImageView.setVisibility(View.GONE); } } } return mRootView; }
From source file:hku.fyp14017.blencode.ui.BackPackActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { //Dismiss ActionMode without effecting checked items if (currentFragment != null && currentFragment.getActionModeActive() && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { ListAdapter adapter = null;// w ww .j av a2s . com if (currentFragment instanceof BackPackScriptFragment) { adapter = ((BackPackScriptFragment) currentFragment).getAdapter(); } else { adapter = currentFragment.getListAdapter(); } ((ScriptActivityAdapterInterface) adapter).clearCheckedItems(); } return super.dispatchKeyEvent(event); }
From source file:com.openerp.base.login.Login.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true);//from ww w. ja v a2 s . c o m this.context = getActivity(); scope = new AppScope(this); // Inflate the layout for this fragment rootView = inflater.inflate(R.layout.fragment_login, container, false); dbListSpinner = (Spinner) rootView.findViewById(R.id.lstDatabases); this.handleArguments((Bundle) getArguments()); this.loadDatabaseList(); getActivity().setTitle(R.string.label_login); getActivity().getActionBar().setDisplayHomeAsUpEnabled(false); getActivity().getActionBar().setHomeButtonEnabled(false); edtUsername = (EditText) rootView.findViewById(R.id.edtUsername); edtPassword = (EditText) rootView.findViewById(R.id.edtPassword); edtPassword.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) { goNext(); } return false; } }); return rootView; }
From source file:com.vikingbrain.dmt.view.RemoteControlActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { int keyaction = event.getAction(); int keyCode = event.getKeyCode(); //Manage key up keys if (keyaction == KeyEvent.ACTION_UP) { if (keyCode == KeyEvent.KEYCODE_BACK) { //Back button, exit the activity onBackPressed();/*w w w .j a v a2s .c o m*/ return true; } else if (keyCode == KeyEvent.KEYCODE_DEL) { //this is for backspace addCharacterToSendQueue(Keyboard2RemoteKey.BACKSPACE.getKeyboardSymbol()); return true; } else { //Any other keyboard key up DmtLogger.d("key pressed", String.valueOf(event.getKeyCode())); char unicodeChar = (char) event.getUnicodeChar(); String keyboardSymbol = String.valueOf(unicodeChar); addCharacterToSendQueue(keyboardSymbol); return true; } } return super.dispatchKeyEvent(event); }
From source file:com.google.android.marvin.mytalkback.ProcessorVolumeStream.java
@Override public boolean onKeyEvent(KeyEvent event) { boolean handled = false; switch (event.getAction()) { case KeyEvent.ACTION_DOWN: handled = handleKeyDown(event.getKeyCode()); break;/*ww w . j a va 2s . c om*/ case KeyEvent.ACTION_UP: handled = handleKeyUp(event.getKeyCode()); break; } if (handled) { // Quickly acquire and release the wake lock so that // PowerManager.ON_AFTER_RELEASE takes effect. mWakeLock.acquire(); mWakeLock.release(); } return handled; }
From source file:com.darly.im.ui.CCPFragment.java
/** * ?/*w ww . ja v a2 s.c o m*/ * @param keyCode * @param event * @return */ public boolean onKeyDown(int keyCode, KeyEvent event) { if (mBaseActivity.onKeyDown(keyCode, event)) { return true; } if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK) && event.getAction() == KeyEvent.ACTION_DOWN) { finish(); return true; } return false; }