List of usage examples for android.widget EditText getText
@Override
public Editable getText()
From source file:com.example.run_tracker.ProfileFragment.java
@Override public void onClick(View arg0) { Log.v(TAG, "click"); AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Enter Password"); alert.setMessage("Please enter your password"); // Set an EditText view to get user input final EditText input = new EditText(getActivity()); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); alert.setView(input);/*from w w w.j a va2 s . c om*/ alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String password = input.getText().toString(); String new_password = null; if (!mPassword1.getText().toString().equals(mPassword2.getText().toString())) { Toast.makeText(getActivity(), "Passwords dont match", Toast.LENGTH_LONG).show(); } else { if (isEmpty(mPassword1) || (isEmpty(mPassword2))) { new_password = password; } else { new_password = mPassword1.getText().toString(); } Make_edit_profile_request(password, new_password); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); }
From source file:com.simplechatclient.android.ProfileRegisterFragment.java
@SuppressLint("DefaultLocale") private void register_nick() { EditText editTextRegisterNick = (EditText) view.findViewById(R.id.editTextRegisterNick); EditText editTextRegisterPassword = (EditText) view.findViewById(R.id.editTextRegisterPassword); EditText editTextRegisterCode = (EditText) view.findViewById(R.id.editTextRegisterCode); String nick = editTextRegisterNick.getText().toString(); String password = editTextRegisterPassword.getText().toString(); String code = editTextRegisterCode.getText().toString(); String[] params = { nick, password, code }; new RegisterUserTask().execute(params); }
From source file:com.rvl.android.getnzb.Search.java
public void btn_handler(View v) { switch (v.getId()) { case R.id.btn_search: EditText ed = (EditText) findViewById(R.id.searchterm); SEARCHTERM = ed.getText().toString().trim().replaceAll(" ", "+"); Spinner categorySpinner = (Spinner) findViewById(R.id.spinnerCategory); SEARCHCATEGORY = SEARCHCATEGORYHASHMAP.get(categorySpinner.getSelectedItem().toString()); Spinner ageSpinner = (Spinner) findViewById(R.id.spinnerAge); SEARCHAGE = SEARCHAGEHASHMAP.get(ageSpinner.getSelectedItem().toString()); Log.d(Tags.LOG, "Searching in " + SEARCHCATEGORY); new searchNZB().execute(SEARCHTERM, SEARCHCATEGORY, SEARCHAGE); break;//from ww w.j a v a 2 s .co m case R.id.buttonMySearches: startMySearch(); break; case R.id.btn_next: if (HITLIST.length == 25) { HITLIST = null; CURRENT_PAGE++; new searchNZB().execute(SEARCHTERM, SEARCHCATEGORY, SEARCHAGE); } else { TextView statusbar = (TextView) findViewById(R.id.statusbar); statusbar.setText("No more matches."); } break; case R.id.btn_previous: HITLIST = null; if (CURRENT_PAGE > 1) CURRENT_PAGE--; new searchNZB().execute(SEARCHTERM, SEARCHCATEGORY, SEARCHAGE); break; case R.id.btn_backtosearch: HITLIST = null; CURRENT_PAGE = 1; SEARCHTERM = ""; setContentView(R.layout.search); TextView statusbar = (TextView) findViewById(R.id.statusbar); statusbar.setText("Enter searchterm and select category."); break; } }
From source file:fm.libre.droid.LibreDroid.java
public void addStation() { final EditText stationEntry = (EditText) findViewById(R.id.stationEntry); stations.add(0, stationEntry.getText().toString()); try {// www.ja v a 2s .c o m FileOutputStream stationFile = openFileOutput("libredroid-custom-stations.conf", Context.MODE_PRIVATE); for (String station : stations) { stationFile.write(station.getBytes()); stationFile.write('\n'); } stationFile.close(); } catch (IOException ex) { Log.w("libredroid", ex.getMessage()); } setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, stations)); this.prevPage(); }
From source file:cc.siara.csv_ml_demo.MainActivity.java
/** * Transforms csv_ml to xml/*from ww w . j a v a 2 s . com*/ */ void toXML() { EditText etInput = (EditText) findViewById(R.id.etInput); CheckBox cbPretty = (CheckBox) findViewById(R.id.cbPretty); MultiLevelCSVParser parser = new MultiLevelCSVParser(); try { Document doc = parser.parseToDOM(new StringReader(etInput.getText().toString()), false); String ex_str = parser.getEx().get_all_exceptions(); if (ex_str.length() > 0) { Toast.makeText(getApplicationContext(), ex_str, Toast.LENGTH_SHORT).show(); if (parser.getEx().getErrorCode() > 0) return; } String xmlString = Util.docToString(doc, cbPretty.isChecked()); if (xmlString.length() > 5 && xmlString.substring(0, 5).equals("<?xml")) xmlString = xmlString.substring(xmlString.indexOf(">") + 1); EditText etOutput = (EditText) findViewById(R.id.etOutput); etOutput.setText(xmlString); // tfOutputSize.setText(String.valueOf(xmlString.length())); } catch (IOException e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } }
From source file:com.loadsensing.app.LoginActivity.java
public void onClick(View v) { // this gets the resources in the xml file // and assigns it to a local variable of type EditText EditText usernameEditText = (EditText) findViewById(R.id.txt_username); EditText passwordEditText = (EditText) findViewById(R.id.txt_password); // the getText() gets the current value of the text box // the toString() converts the value to String data type // then assigns it to a variable of type String String sUserName = usernameEditText.getText().toString(); String sPassword = passwordEditText.getText().toString(); // Definimos constructor de alerta para los avisos posteriores AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog = new AlertDialog.Builder(this).create(); // call the backend using Get parameters String address = SERVER_HOST + "?user=" + sUserName + "&pass=" + sPassword + ""; if (sUserName.equals("") || sPassword.equals("")) { // error alert alertDialog.setTitle(getResources().getString(R.string.error)); alertDialog.setMessage(getResources().getString(R.string.empty_fields)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; }//from w w w . j a v a 2 s.co m }); alertDialog.show(); } else if (!checkConnection(this.getApplicationContext())) { alertDialog.setTitle(getResources().getString(R.string.error)); alertDialog.setMessage(getResources().getString(R.string.error_no_internet)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.show(); } else { try { showBusyCursor(true); progress = ProgressDialog.show(this, getResources().getString(R.string.pantalla_espera_title), getResources().getString(R.string.iniciando_sesion), true); Log.d(DEB_TAG, "Requesting to " + address); JSONObject json = JsonClient.connectJSONObject(address); CheckBox rememberUserPassword = (CheckBox) findViewById(R.id.remember_user_password); if (rememberUserPassword.isChecked()) { setSharedPreference("login", sUserName); setSharedPreference("password", sPassword); } else { setSharedPreference("login", ""); setSharedPreference("password", ""); } if (json.getString("session") != "0") { progress.dismiss(); // Guardamos la session en SharedPreferences para utilizarla // posteriormente setSharedPreference("session", json.getString("session")); // Sessin correcta. StartActivity de la home Intent intent = new Intent(); intent.setClass(this.getApplicationContext(), HomeActivity.class); startActivity(intent); } else { progress.dismiss(); alertDialog.setTitle(getResources().getString(R.string.error)); alertDialog.setMessage(getResources().getString(R.string.error_login)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.show(); } } catch (JSONException e) { progress.dismiss(); Log.d(DEB_TAG, "Error parsing data " + e.toString()); } showBusyCursor(false); } }
From source file:palamarchuk.smartlife.app.RegisterActivity.java
private boolean isEmpty(EditText editText) { return editText.getText().toString().length() == 0; }
From source file:cc.siara.csv_ml_demo.MainActivity.java
/** * Transforms csv_ml to JSON Object/*from w w w. java 2s. c o m*/ */ void toJSON() { EditText etInput = (EditText) findViewById(R.id.etInput); CheckBox cbPretty = (CheckBox) findViewById(R.id.cbPretty); MultiLevelCSVParser parser = new MultiLevelCSVParser(); try { JSONObject jo = parser.parseToJSO(new StringReader(etInput.getText().toString()), false); String ex_str = parser.getEx().get_all_exceptions(); if (ex_str.length() > 0) { Toast.makeText(getApplicationContext(), ex_str, Toast.LENGTH_LONG).show(); if (parser.getEx().getErrorCode() > 0) return; } String outStr = null; if (cbPretty.isChecked()) { JSONWriter jw = new JSONWriter(); try { jo.writeJSONString(jw); } catch (IOException e) { e.printStackTrace(); } outStr = jw.toString(); } else outStr = jo.toJSONString(); EditText etOutput = (EditText) findViewById(R.id.etOutput); etOutput.setText(outStr); // tfOutputSize.setText(String.valueOf(outStr.length())); } catch (IOException e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } }
From source file:br.com.GUI.perfil.HomePersonal.java
public boolean onOptionsItemSelected(MenuItem item) { // Take appropriate action for each action item click switch (item.getItemId()) { case R.id.actSolicitacoesDeAmizadePersonal: ArrayList<Aluno> solicitacoes = new Aluno().buscarAlunoNaoConfirmadoPorPersonalWeb("", pref.getString("usuario", null)); if (!solicitacoes.isEmpty()) { Intent i = new Intent(this, SolicitacoesDeAmizade.class); startActivity(i);//from ww w .ja va2 s. c om } else { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Ops..."); alertDialog.setMessage(R.string.label_voce_nao_possui_solicitacoes_de_amizade); alertDialog.setIcon(R.drawable.profile); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } return true; case R.id.actLogoutPersonal: finish(); Intent login = new Intent(this, Login.class); login.putExtra("logout", true); editor.clear(); editor.commit(); startActivity(login); return true; case R.id.actAdicionarAlunos: Intent adicionarAlunos = new Intent(this, BuscarUsuario.class); startActivity(adicionarAlunos); return true; case R.id.actAlterarDadosPessoaisPersonal: if (pref.getBoolean("isFacebookUser", false)) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(HomePersonal.this); alertDialog.setTitle("Erro"); alertDialog.setMessage( "Seu cadastro est vinculado ao Facebook, sendo assim, no possivel alterao de informaes pessoais"); alertDialog.setIcon(R.drawable.profile); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } else { Intent alterarDados = new Intent(this, AlterarDadosPessoais.class); startActivity(alterarDados); } return true; case R.id.actPerfil: Intent perfilIntent = new Intent(this, PerfilPersonal.class); startActivity(perfilIntent); return true; case R.id.actNovaAvaliacao: Intent avaliacoesIntent = new Intent(this, AvaliarGorduraCorporal.class); startActivity(avaliacoesIntent); return true; case R.id.actNovoTreinamento: AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Ops..."); alertDialog.setMessage("Digite um nome para o novo treinamento"); alertDialog.setIcon(R.drawable.critical); // Set an EditText view to get user input final EditText input = new EditText(this); alertDialog.setView(input); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Treinamento t = new Treinamento(0, input.getText().toString(), null, null, pref.getString("usuario", null), null); //Log.i("interface: treinamento", t.toString()); try { int resultado = t.salvarTreinamentoWeb(b); if (resultado > 0) { Log.i("interface: salvei web", "salvei web"); t.setCodTreinamento(resultado); if (t.salvarTreinamento(b, pref.getString("usuario", null))) { Log.i("interface: salvei local", "salvei local"); Toast.makeText(HomePersonal.this, "Salvo com sucesso!", Toast.LENGTH_SHORT).show(); } } } catch (Exception ex) { ex.printStackTrace(); Toast.makeText(HomePersonal.this, "Erro ao salvar!", Toast.LENGTH_SHORT).show(); } } }); alertDialog.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); // Showing Alert Message alertDialog.show(); } return false; }
From source file:app.abhijit.iter.MainActivity.java
private void setupAddStudentButton() { final Button addStudentButton = (Button) findViewById(R.id.student_add); addStudentButton.setOnClickListener(new View.OnClickListener() { @Override//from www. ja v a 2s. co m public void onClick(View v) { EditText addStudentEditText = (EditText) findViewById(R.id.student_registration_number_input); String registrationNumber = addStudentEditText.getText().toString(); ((MainApplication) getApplication()).getStudentDataSource().select(registrationNumber); addStudentEditText.setText(""); InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow( getCurrentFocus() == null ? null : getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawers(); } }); }