10 ответов:
если вы проверяете документы для
EditText, вы найдетеsetText()метод. Он принимает вStringиTextView.BufferType. Например:EditText editText = (EditText)findViewById(R.id.edit_text); editText.setText("Google is your friend.", TextView.BufferType.EDITABLE);
String string="this is a text"; editText.setText(string)Я обнаружил, что String является полезным косвенным подклассом CharSequence
http://developer.android.com/reference/android/widget/TextView.html найти setText (CharSequence text)
http://developer.android.com/reference/java/lang/CharSequence.html
String text = "Example"; EditText edtText = (EditText) findViewById(R.id.edtText); edtText.setText(text);зацените
EditTextпринимать только строковые значения, если необходимо преобразовать его в строку.Если int, double, long значение, do:
String.value(value);
использовать+, оператор конкатенации строк:
ed = (EditText) findViewById (R.id.box); int x = 10; ed.setText(""+x);или использовать
String.valueOf(int): ed.setText(String.valueOf(x));или использовать
Integer.toString(int): ed.setText(Integer.toString(x));
Вы можете установить
android:text="your text";<EditText android:id="@+id/editTextName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/intro_name"/>
editTextObject.setText(CharSequence)http://developer.android.com/reference/android/widget/TextView.html#setText(java.lang.CharSequence)
вам нужно:
- объявить
EditText in the xml file- найти
EditTextв деятельности- установите текст в
EditText
EditText editText = (EditText)findViewById(R.id.edit_text); editText.setText("Google is your friend.", TextView.BufferType.EDITABLE);Не слишком технически, и я уверен, что вы получите его так же, как и я, но он "редактируемый".
public boolean checkUser(String email, String password) { // array of columns to fetch String[] columns = { COLUMN_USER_ID }; SQLiteDatabase db = this.getReadableDatabase(); // selection criteria String selection = COLUMN_USER_EMAIL + " = ?" + " AND " + COLUMN_USER_PASSWORD + " = ?"; //selection arguments String[] selectionArgs = {email, password}; Cursor cursor = db.query(TABLE_USER, //Table to query columns, //columns to return selection, //columns for the WHERE clause selectionArgs, //The values for the WHERE clause null, //group the rows null, //filter by row groups null); //The sort order int cursorCount = cursor.getCount(); cursor.close(); db.close(); if (cursorCount > 0) { return true; } return false; }
это решение в Котлин
val editText: EditText = findViewById(R.id.main_et_name) editText.setText("This is a text.")
Comments