私は後続の画面にユーザーIDを渡す必要がある単純なログインアプリケーションをやっています。しかし、私は変数にユーザー名フィールドを取得していません。テキストを編集するgetText()。toString()は空白を返します
public static String user;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText username = (EditText)findViewById(R.id.etUserName);
EditText password = (EditText)findViewById(R.id.etPwd);
Button blogin = (Button)findViewById(R.id.bLogin);
user = username.getText().toString();// Here user variable is blank!!!!!!!!!!!!!!!
親切に助けてください!
それは常に空白のonCreate()メソッドでは、あなたが唯一のテスト・ケース.FOR値 – Vickyexpert
は大丈夫得ることができ、ボタンのクリックイベントにそれを記述する必要があります「私はsouravだ」( 'username.setTextを追加); ''ユーザーの前に ' –
[編集テキストフィールドの値を取得]の可能な複製(http://stackoverflow.com/questions/4531396/get-value-of-a-edit-text-field) – Veer3383