List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:eu.veldsoft.adsbobball.ActivityStateEnum.java
private void promptUsername() { final EditText input = new EditText(this); new AlertDialog.Builder(this).setTitle(R.string.namePrompt).setMessage(R.string.highScoreAchieved) .setView(input).setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Editable value = input.getText(); String valueString = value.toString().trim(); if (valueString.isEmpty()) { valueString = "Unknown"; }//from ww w .j a va 2s . co m scores.addScore(valueString, gameManager.getCurrGameState().getPlayer(playerId).getScore()); showTopScores(); } }).show(); }
From source file:samsungsami.io.example.samiremotecontrol.DeviceActivity.java
public void addFallback() { final ObjectMapper mapper = new ObjectMapper(); TextView textView = new TextView(this); textView.setText("fallback"); LinearLayout gridLayout = (LinearLayout) findViewById(R.id.gridLayout); gridLayout.addView(textView);/*from ww w. java 2 s . c o m*/ final EditText editText; editText = new EditText(this); Button button = new Button(this); button.setText("send"); button.setTextAppearance(this, android.R.style.TextAppearance_Small); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { MessagesApi msgApi = new MessagesApi(); msgApi.setBasePath(SamiHelper.SAMIHUB_BASE_PATH); msgApi.getInvoker().addDefaultHeader("Authorization", "bearer " + SamiHelper.getAccessToken()); sendCommandMessage = new Message(); sendCommandMessage.setSdid(did); sendCommandMessage.setDdid(did); sendCommandMessage.setToken("fakeToken"); try { Map<String, Object> messageData = mapper.readValue(editText.getText().toString(), Map.class); sendCommandMessage.setData(messageData); new CallPostMessageApiInBackground().execute(msgApi); } catch (IOException e) { } } }); gridLayout.addView(editText); gridLayout.addView(button); }
From source file:com.peppermint.peppermint.ui.AnswerFragment.java
/** * Shows the custom message entry dialog. *//*from w w w.jav a2 s . c om*/ public void showCustomMessageDialog() { // Create an alert dialog containing an EditText final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final EditText et = new EditText(builder.getContext()); builder.setCancelable(true).setView(et) .setPositiveButton(R.string.custom_message_send, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // The order is arranged in a way that the popup will be destroyed when the // InCallActivity is about to finish. final String textMessage = et.getText().toString().trim(); dismissCustomMessagePopup(); // getPresenter().rejectCallWithMessage(textMessage); Log.d(this, "Call rejected with message"); LOGD(TAG, "Call rejected with mesage" + textMessage); MainActivity.hangupCall(); callActivity.finish(); } }).setNegativeButton(R.string.custom_message_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismissCustomMessagePopup(); Log.d(this, "Dismiss with custom message"); // getPresenter().onDismissDialog(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { dismissCustomMessagePopup(); Log.d(this, "Dismiss with custom message"); // getPresenter().onDismissDialog(); } }).setTitle(R.string.respond_via_sms_custom_message); mCustomMessagePopup = builder.create(); // Enable/disable the send button based on whether there is a message in the EditText et.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { final Button sendButton = mCustomMessagePopup.getButton(DialogInterface.BUTTON_POSITIVE); sendButton.setEnabled(s != null && s.toString().trim().length() != 0); } }); // Keyboard up, show the dialog mCustomMessagePopup.getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); mCustomMessagePopup.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); mCustomMessagePopup.show(); // Send button starts out disabled final Button sendButton = mCustomMessagePopup.getButton(DialogInterface.BUTTON_POSITIVE); sendButton.setEnabled(false); }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
private void showAddrEnterDialog() { // Set the current dialog currentDialog = ADDRESS_ENTER_DIALOG_ID; // Build Address Enter Dialog AlertDialog.Builder addrEnterBuilder = new AlertDialog.Builder(this); addrEnterBuilder.setTitle("Step 3: Enter Location Name / Address"); // Initialize EditText for user to type the desired address addressET = new EditText(this); addressET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE); addrEnterBuilder.setView(addressET); // Set Listeners addrEnterBuilder.setPositiveButton("Search", mAddrEnterOnClickListner); // Finish the activity when the user presses cancel addrEnterBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setResult(RESULT_OK);// w w w.j a v a 2 s. c o m finish(); } }); addrEnterBuilder.setOnKeyListener(mBackKeyListener); // Show Address Enter Dialog addrEnterDialog = addrEnterBuilder.create(); addrEnterDialog.show(); }
From source file:com.metinkale.prayerapp.vakit.AddCity.java
public void addFromCSV(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.addFromCSV).setItems(R.array.addFromCSV, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 0) { FileChooser chooser = new FileChooser(AddCity.this); chooser.setExtension("csv"); chooser.showDialog();//from w w w . j a v a 2 s. co m chooser.setFileListener(new FileChooser.FileSelectedListener() { @Override public void fileSelected(File file) { String name = file.getName(); if (name.contains(".")) name = name.substring(0, name.lastIndexOf(".")); WebTimes.add(Source.CSV, name, file.toURI().toString(), 0, 0); } }); } else { AlertDialog.Builder alert = new AlertDialog.Builder(AddCity.this); final EditText editText = new EditText(AddCity.this); editText.setHint("http(s)://example.com/prayertimes.csv"); alert.setView(editText); alert.setTitle(R.string.csvFromURL); alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { String url = editText.getText().toString(); String name = url.substring(url.lastIndexOf("/") + 1); if (name.contains(".")) name = name.substring(0, name.lastIndexOf(".")); WebTimes.add(Source.CSV, name, url, 0, 0); } }); alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); alert.show(); } } }); builder.show(); }
From source file:com.experiment.chickenjohn.materialdemo.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*from w w w . j a v a 2 s . c om*/ public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); switch (id) { case R.id.rate_setting: rateSettinginEdit = new EditText(this); new AlertDialog.Builder(this).setTitle("(Hz)").setView(rateSettinginEdit) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { rateSettinginString = rateSettinginEdit.getText().toString(); EcgData.setRecordRate(Double.valueOf(rateSettinginString).doubleValue()); Log.v("recordrate", Double.toString(EcgData.getRECORDRATE())); } }).show(); break; case R.id.data_output: if (ecgDatabaseManager.outputRecord()) { Toast.makeText(this, "??", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "???", Toast.LENGTH_LONG).show(); } break; case R.id.data_clear: if (ecgDatabaseManager.clearRecord()) { Toast.makeText(this, "??", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "?", Toast.LENGTH_LONG).show(); } break; case R.id.spo2_switch: if (receiveSpo2) { item.setTitle("SpO2"); receiveSpo2 = false; btManager.setSpo2Receiver(receiveSpo2); drawSurfaceView.resetSurfaceViewX(); } else { item.setTitle("SpO2"); receiveSpo2 = true; btManager.setSpo2Receiver(receiveSpo2); drawSurfaceView.resetSurfaceViewX(); } drawSurfaceView.resetCanvas(); break; case R.id.btconnection: btManager.enableBluetooth(); break; default: break; } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:bruce.kk.brucetodos.MainActivity.java
/** * ? /*from w w w.j av a2s . co m*/ */ private void showAddPop() { final EditText editText = new EditText(MainActivity.this); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); editText.setLayoutParams(layoutParams); // editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); editText.setTextColor(getResources().getColor(android.R.color.holo_green_light)); editText.setHint("?~"); editText.setHintTextColor(getResources().getColor(android.R.color.holo_orange_dark)); editText.setBackgroundColor(getResources().getColor(android.R.color.black)); final PopupWindow popupWindow = new PopupWindow(editText, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setBackgroundDrawable(new BitmapDrawable()); // ? popupWindow.setTouchable(true); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(contentMain, Gravity.CENTER, 0, 0); popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { LogDetails.d(": " + editText.getText().toString()); if (!TextUtils.isEmpty(editText.getText().toString().trim())) { ProgressDialogUtils.showProgressDialog(); UnFinishItem item = new UnFinishItem(); Date date = new Date(); item.createDay = date; item.content = editText.getText().toString().trim(); item.modifyDay = date; dataList.add(item); refreshData(true); presenter.addItem(item); } } }); }
From source file:nz.ac.otago.psyanlab.common.designer.program.stage.EditPropPropertiesFragment.java
/** * Creates an edit text entry field that allows the user to enter a * fractional number.//from ww w.j av a 2 s . c o m * * @param signedAnnotation * @return EditText */ private View newFloatInputView(boolean isSigned, float f) { EditText view = new EditText(getActivity()); if (isSigned) { view.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); } else { view.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); } view.setSingleLine(); view.setText(String.valueOf(f)); return view; }
From source file:com.doplgangr.secrecy.views.VaultsListFragment.java
void add() { final View dialogView = View.inflate(context, R.layout.new_credentials, null); final EditText password = new EditText(context); password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); new AlertDialog.Builder(context).setTitle(getString(R.string.Vault__new)).setView(dialogView) .setPositiveButton(getString(R.string.OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String name = ((EditText) dialogView.findViewById(R.id.newName)).getText().toString(); String password = ((EditText) dialogView.findViewById(R.id.stealth_keycode)).getText() .toString(); String Confirmpassword = ((EditText) dialogView.findViewById(R.id.confirmPassword)) .getText().toString(); File directory = new File(Storage.getRoot().getAbsolutePath() + "/" + name); if (!password.equals(Confirmpassword) || "".equals(password)) passwordWrong(); else if (directory.mkdirs()) { // Create vault to initialize the vault header ProgressDialog progress = new ProgressDialog(context); progress.setIndeterminate(true); progress.setMessage(getString(R.string.Vault__initializing)); progress.setCancelable(false); progress.show(); createVaultInBackground(name, password, directory, dialog, progress); } else failedtocreate(); }/*w w w . j av a 2 s. c o m*/ }).setNegativeButton(getString(R.string.CANCEL), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }).show(); }
From source file:com.emobc.android.activities.generators.FormActivityGenerator.java
private EditText insertTextField(final Activity activity, FormDataItem dataItem) { EditText txt = new EditText(activity); txt.setTag(dataItem.getFieldName()); txt.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override//from ww w. ja v a2 s .com public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { InputMethodManager imm = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } } }); return txt; }