How To Set Text In An EditText

2019-01-05 00:27发布

How can I set the text of an EditText?

10条回答
时光不老,我们不散
2楼-- · 2019-01-05 01:11
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;
}
查看更多
走好不送
3楼-- · 2019-01-05 01:15
EditText editText = (EditText)findViewById(R.id.edit_text);
editText.setText("Google is your friend.", TextView.BufferType.EDITABLE);

Not to be overly technical, and I am sure you'd get it just as I have, but it is 'Editable'.

查看更多
我想做一个坏孩纸
4楼-- · 2019-01-05 01:19

If you check the docs for EditText, you'll find a setText() method. It takes in a String and a TextView.BufferType. For example:

EditText editText = (EditText)findViewById(R.id.edit_text);
editText.setText("Google is your friend.", TextView.BufferType.EDITABLE);
查看更多
Summer. ? 凉城
5楼-- · 2019-01-05 01:19
String text = "Example";
EditText edtText = (EditText) findViewById(R.id.edtText);
edtText.setText(text);

Check it out EditText accept only String values if necessary convert it to string.

If int, double, long value, do:

String.value(value);
查看更多
登录 后发表回答