文本框取值
我在文本框中取不到值啊
package com.ab.jiugongge;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
private Button buttonlog;
private EditText et1;
private EditText et2;
private String username;
private String password="";
private String x = "x";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonlog = (Button)findViewById(R.id.button1);
et1 = (EditText) findViewById(R.id.editText1);
et2 = (EditText) findViewById(R.id.editText2);
username = et1.getText().toString();
password = et2.getText().toString();
x="xx";
buttonlog.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if("qiezi".equals(username)&&"217".equals(password)){
Intent intent = new Intent(MainActivity.this, JActivaty.class);
startActivity(intent);
}else{
Toast.makeText(MainActivity.this, "登录失败"+username+password+x,1).show();
}
}
});