List of usage examples for android.view KeyEvent KEYCODE_ENTER
int KEYCODE_ENTER
To view the source code for android.view KeyEvent KEYCODE_ENTER.
Click Source Link
From source file:com.unipiazza.material2stepslogin.fragments.FirstStepFragment.java
@Nullable @Override/* www. j av a 2 s . c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.first_login_view, null); email = (AutoCompleteTextView) view.findViewById(R.id.email); next = (Button) view.findViewById(R.id.buttonNext); progressBarFirst = (ProgressBar) view.findViewById(R.id.progressBarFirst); layoutFirst = (LinearLayout) view.findViewById(R.id.layoutFirst); logo = (ImageView) view.findViewById(R.id.logo); descriptionText = (TextView) view.findViewById(R.id.descriptionText); registerText = (TextView) view.findViewById(R.id.registerText); buttonRegistra = (Button) view.findViewById(R.id.buttonRegistra); progressBarFirst.setVisibility(View.GONE); if (mtsl != null) { view.setBackgroundColor(mtsl.getFirst_step_background_color()); logo.setImageResource(mtsl.getLogo()); descriptionText.setText(mtsl.getDescription()); if (mtsl.getRegister_description() != 0) registerText.setText(mtsl.getRegister_description()); if (mtsl.getRegister_description_text_color() != 0) registerText.setTextColor(mtsl.getRegister_description_text_color()); if (mtsl.getRegister_text() != 0) buttonRegistra.setText(mtsl.getRegister_text()); if (mtsl.getRegister_background() != 0) buttonRegistra.setBackgroundResource(mtsl.getRegister_background()); if (mtsl.getButton_register_text_color() != 0) buttonRegistra.setTextColor(mtsl.getButton_register_text_color()); if (mtsl.getEditText_email_text_color() != 0) email.setTextColor(mtsl.getEditText_email_text_color()); if (mtsl.getEdittext_email_background() != 0) email.setBackgroundResource(mtsl.getEdittext_email_background()); if (mtsl.getButton_next_background() != 0) next.setBackgroundResource(mtsl.getButton_next_background()); if (mtsl.getButton_next_text_color() != 0) next.setTextColor(mtsl.getButton_next_text_color()); if (mtsl.getDescription_text_color() != 0) descriptionText.setTextColor(mtsl.getDescription_text_color()); } email.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) { next.performClick(); } return false; } }); checkAccountPermissions(); next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { progressBarFirst.setVisibility(View.VISIBLE); layoutFirst.setVisibility(View.GONE); mListener.onNextClicked(email.getText().toString()); InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } }); buttonRegistra.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mListener.onRegisterClicked(); } }); return view; }
From source file:org.xbmc.kore.ui.generic.SendTextDialogFragment.java
/** * Create the dialog/*from ww w .jav a 2 s. c o m*/ * @param savedInstanceState Saved state * @return Created dialog */ @NonNull @Override @SuppressWarnings("InflateParams") public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final String title = getArguments().getString(TITLE_KEY, getString(R.string.send_text)); View dialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_send_text, null); textToSend = (EditText) dialogView.findViewById(R.id.text_to_send); finishAfterSend = (CheckBox) dialogView.findViewById(R.id.send_text_done); builder.setTitle(title).setView(dialogView) .setPositiveButton(R.string.send, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mListener.onSendTextFinished(textToSend.getText().toString(), finishAfterSend.isChecked()); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mListener.onSendTextCancel(); } }); final Dialog dialog = builder.create(); textToSend.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); textToSend.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEND) { onSendTextFinished(); } // handles enter key on external keyboard, issue #99 else if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED && (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { onSendTextFinished(); } dialog.dismiss(); return false; } private void onSendTextFinished() { mListener.onSendTextFinished(textToSend.getText().toString(), finishAfterSend.isChecked()); } }); return dialog; }
From source file:com.google.mist.plot.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { toggleRecording(RecordingType.POSITIVE); return true; }/*from w w w. j a v a 2s .com*/ if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { toggleRecording(RecordingType.NEGATIVE); return true; } /* To label magnet pulls with ground truth, connect with ADB and run command: $ input keyevent 66 or from console, not inside adb shell, $ adb shell input keyevent 66 or connect a bluetooth keyboard and hit "enter" key */ if (mIsRecording && (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT)) { mVibrator.vibrate(30); int recordedLabel = 0; switch (keyCode) { case KeyEvent.KEYCODE_ENTER: recordedLabel = POSITIVE_LABEL; break; case KeyEvent.KEYCODE_DPAD_UP: recordedLabel = UP_LABEL; break; case KeyEvent.KEYCODE_DPAD_DOWN: recordedLabel = DOWN_LABEL; break; case KeyEvent.KEYCODE_DPAD_LEFT: recordedLabel = LEFT_LABEL; break; case KeyEvent.KEYCODE_DPAD_RIGHT: recordedLabel = RIGHT_LABEL; break; } long lastFiring = mSensorTime.get(mSensorTime.size() - 1); mPositivesTime.add(lastFiring); mPositivesData.add(recordedLabel); } return super.onKeyDown(keyCode, event); }
From source file:com.mooshim.mooshimeter.main.PreferencesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final PreferencesActivity mThis = this; Intent intent = getIntent();// w w w. ja v a 2 s . c o m mMeter = ScanActivity.getDeviceWithAddress(intent.getStringExtra("addr")); setContentView(R.layout.activity_meter_preference); final EditText name_editor = (EditText) findViewById(R.id.meter_rename_edit); rateButtons[0] = (Button) findViewById(R.id.rate_button0); rateButtons[1] = (Button) findViewById(R.id.rate_button1); rateButtons[2] = (Button) findViewById(R.id.rate_button2); rateButtons[3] = (Button) findViewById(R.id.rate_button3); if (mMeter.meter_name.name != null) { name_editor.setText(mMeter.meter_name.name); } else { name_editor.setText("Mooshimeter V.1"); } name_editor.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { mMeter.meter_name.name = String.valueOf(name_editor.getText()); mMeter.meter_name.send(); Log.d(null, "Name sent"); Toast.makeText(mThis, "Name Sent", Toast.LENGTH_SHORT).show(); return true; } return false; } }); rateButtonRefresh(); }
From source file:com.mobicage.rogerthat.plugins.friends.ServiceSearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.service_search); mSearchCategoryLabels = (LinearLayout) findViewById(R.id.search_category); mSearchCategoryViewFlipper = (SafeViewFlipper) findViewById(R.id.search_result_lists); mSearchInfoByCategory = new HashMap<String, ServiceSearchActivity.SearchInfo>(); mSearchInfoByListView = new HashMap<AbsListView, ServiceSearchActivity.SearchInfo>(); mGestureScanner = new GestureDetector(new ViewFlipperSlider(mOnSwipeLeft, mOnSwipeRight)); final Context ctx = this; final EditText editText = (EditText) findViewById(R.id.search_text); editText.setOnEditorActionListener(new OnEditorActionListener() { @Override/* w ww . j a v a 2s . c o m*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) { if (!TextUtils.isEmptyOrWhitespace(mSearchString)) { UIUtils.hideKeyboard(ServiceSearchActivity.this, v); launchFindServiceCall(); return true; } } return false; } }); editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { mSearchString = s.toString(); clearSearches(); } }); findViewById(R.id.search_button).setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { if (TextUtils.isEmptyOrWhitespace(mSearchString)) { mSearchString = ""; } UIUtils.hideKeyboard(ctx, editText); clearSearches(); launchFindServiceCall(); } }); }
From source file:org.ednovo.goorusearchwidget.HomeScreenActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home_screen); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); headerSearch = (RelativeLayout) findViewById(R.id.layoutHeader); imgViewGooruSearch = (ImageView) findViewById(R.id.ivGooruLogo); imgViewSections = (ImageView) findViewById(R.id.imgViewSections); imgViewSettings = (ImageView) findViewById(R.id.imgViewSettings); imageViewClose = (ImageView) findViewById(R.id.imageViewClose); imageViewSearch = (ImageView) findViewById(R.id.imageViewSearch); editTexthome = (EditText) findViewById(R.id.textViewSearch); switchResColl = (Switch) findViewById(R.id.switchResColl); dialog = new ProgressDialog(this); imm = (InputMethodManager) this.getSystemService(Service.INPUT_METHOD_SERVICE); new Loginform().execute(); switchResColl.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override//from www. j a va2s.c om public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if (isChecked) { Log.i("Hello", "True"); searchCriteria = true; } else { Log.i("Hello", "False"); searchCriteria = false; } } }); editTexthome.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: searchKeyword = editTexthome.getText().toString().trim(); if (searchKeyword.isEmpty() || searchKeyword.length() == 0) { } else { if (!searchCriteria) { Log.i("Resources", searchKeyword); Intent intentResResults = new Intent(getBaseContext(), SearchResults_resource.class); Bundle extras = new Bundle(); extras.putString("keyWord", searchKeyword); intentResResults.putExtras(extras); startActivity(intentResResults); finish(); } } return true; default: break; } } return false; } }); imageViewClose.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { finish(); } }); imgViewGooruSearch.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intentResResults = new Intent(getBaseContext(), SearchDialogpopup.class); startActivity(intentResResults); } }); }
From source file:com.orangelabs.rcs.ri.messaging.chat.ChatView.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* Set layout */ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.chat_view);/*from ww w . j a v a 2 s. c o m*/ initialize(); HistoryUriBuilder uriBuilder = new HistoryUriBuilder(HistoryLog.CONTENT_URI); uriBuilder.appendProvider(ChatLog.Message.HISTORYLOG_MEMBER_ID); uriBuilder.appendProvider(FileTransferLog.HISTORYLOG_MEMBER_ID); mUriHistoryProvider = uriBuilder.build(); /* Set message composer callbacks */ mComposeText = (EditText) findViewById(R.id.userText); mComposeText.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (KeyEvent.ACTION_DOWN != event.getAction()) { return false; } switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: sendText(); return true; } return false; } }); mComposeText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // Check if the text is not null. // we do not wish to consider putting the edit text back to null // (like when sending message), is having activity if (!TextUtils.isEmpty(s)) { // Warn the composing manager that we have some activity if (mComposingManager != null) { mComposingManager.hasActivity(); } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); /* Set send button listener */ Button sendBtn = (Button) findViewById(R.id.send_button); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendText(); } }); /* Initialize the adapter. */ mAdapter = new ChatCursorAdapter(this, isSingleChat()); // Associate the list adapter with the ListView. ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(mAdapter); registerForContextMenu(listView); if (!isServiceConnected(RcsServiceName.CHAT, RcsServiceName.CONTACT, RcsServiceName.CAPABILITY, RcsServiceName.FILE_TRANSFER)) { showMessageThenExit(R.string.label_service_not_available); return; } startMonitorServices(RcsServiceName.CHAT, RcsServiceName.CONTACT, RcsServiceName.CAPABILITY, RcsServiceName.FILE_TRANSFER); mChatService = getChatApi(); mFileTransferService = getFileTransferApi(); processIntent(getIntent()); }
From source file:hku.fyp14017.blencode.ui.dialogs.OverwriteRenameDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(context) .inflate(hku.fyp14017.blencode.R.layout.dialog_overwrite_project, null); replaceButton = (RadioButton) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_radio_replace); replaceButton.setOnClickListener(this); renameButton = (RadioButton) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_radio_rename); renameButton.setOnClickListener(this); projectText = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_edit); projectText.setText(programName);// w w w . ja va2s . c o m projectTextView = (TextView) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_edit_text); projectTextLine = dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_edit_line); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(hku.fyp14017.blencode.R.string.overwrite_text) .setPositiveButton(hku.fyp14017.blencode.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton(hku.fyp14017.blencode.R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(context, hku.fyp14017.blencode.R.string.notification_download_project_cancel, Toast.LENGTH_SHORT).show(); } }) .create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { handleOkButton(); } }); } }); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { boolean okButtonResult = handleOkButton(); if (okButtonResult) { dismiss(); } return okButtonResult; } else if (keyCode == KeyEvent.KEYCODE_BACK) { Toast.makeText(context, hku.fyp14017.blencode.R.string.notification_download_project_cancel, Toast.LENGTH_SHORT).show(); return true; } return false; } }); return dialog; }
From source file:au.com.cybersearch2.classyfy.MainActivityTest.java
public void test_search() throws Throwable { final MainActivity mainActivity = getActivity(); Instrumentation instrumentation = getInstrumentation(); ActivityMonitor am = instrumentation.addMonitor(TitleSearchResultsActivity.class.getName(), null, false); assertThat(instrumentation.invokeMenuActionSync(mainActivity, R.id.action_search, 0)).isTrue(); ActionBar actionBar = mainActivity.getSupportActionBar(); assertThat(actionBar).isNotNull();//from ww w . j a va 2s .c o m final FragmentManager sfm = mainActivity.getSupportFragmentManager(); runTestOnUiThread(new Runnable() { public void run() { sfm.executePendingTransactions(); } }); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_I); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_N); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_F); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_ENTER); runTestOnUiThread(new Runnable() { public void run() { sfm.executePendingTransactions(); } }); TitleSearchResultsActivity titleSearchResultsActivity = (TitleSearchResultsActivity) getInstrumentation() .waitForMonitorWithTimeout(am, 10000); assertThat(titleSearchResultsActivity).isNotNull(); assertThat(titleSearchResultsActivity.taskHandle).isNotNull(); synchronized (titleSearchResultsActivity.taskHandle) { titleSearchResultsActivity.taskHandle.wait(10000); } assertThat(titleSearchResultsActivity.taskHandle.getStatus()).isEqualTo(WorkStatus.FINISHED); SimpleCursorAdapter adapter = titleSearchResultsActivity.adapter; for (int i = 0; i < adapter.getCount(); i++) { Cursor cursor = (Cursor) adapter.getItem(i); int column = cursor.getColumnIndexOrThrow(SearchManager.SUGGEST_COLUMN_TEXT_1); assertThat(INF_LIST[i]).isEqualTo(cursor.getString(column)); } }
From source file:net.inbox.Pager.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Show first use help boolean show_help = false; // Init SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (!prefs.contains("initialized")) { PreferenceManager.setDefaultValues(this, R.xml.settings, false); prefs.edit().putBoolean("initialized", true).apply(); // Initial values that don't have a preference screen prefs.edit().putBoolean("imap_or_pop", true).apply(); prefs.edit().putBoolean("using_smtp", false).apply(); prefs.edit().putBoolean("enable_pw", false).apply(); show_help = true;//from w w w .j a v a 2 s .co m } if (show_help || !prefs.getBoolean("enable_pw", false)) { init_db("cleartext"); // Initial entry view View v = View.inflate(this, R.layout.pager, null); v.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in)); setContentView(v); rv_main = (RelativeLayout) findViewById(R.id.app_main); rv_main.setVisibility(View.VISIBLE); rv_main.setAlpha(0.01f); rv_main.animate().alpha(1f).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); activity_load(); } }); } else { // Initial entry view View v = View.inflate(this, R.layout.pager, null); v.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in)); setContentView(v); // Entry text edit llay_pw = (LinearLayout) findViewById(R.id.llay_pw); llay_pw.setVisibility(View.VISIBLE); rv_main = (RelativeLayout) findViewById(R.id.app_main); et_pw = (EditText) findViewById(R.id.pw); et_pw.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int key, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && key == KeyEvent.KEYCODE_ENTER) { init_db(et_pw.getText().toString()); et_pw.setText(""); if (unlocked) { activity_load(); fade_in_ui(); } else { if (++over >= 3) finish(); } return true; } return false; } }); } // Helper dialog if (show_help) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(true); builder.setTitle(getString(R.string.helper_title)); builder.setMessage(getString(R.string.helper_msg)); builder.setPositiveButton(getString(android.R.string.ok), null); builder.setNegativeButton(getString(R.string.btn_pw), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(getApplicationContext(), Settings.class)); overridePendingTransition(R.anim.right_in, R.anim.right_out); } }); builder.show(); } }