我在一个自定义的登录对话框中设置两个输入用户名和密码的EditText,但是只能获取到初值,求大神指点~~~
代码如下:
b6=(Button) findViewById(com.example.learn.R.id.anniu6);
    b6.setOnClickListener(new OnClickListener() {


public void onClick(View v) {

/*LinearLayout lin=(LinearLayout)getLayoutInflater().inflate(com.example.learn.R.layout.dierge, null);
EditText yong=(EditText) lin.findViewById(com.example.learn.R.id.shuruyonghuming);
EditText mi=(EditText) lin.findViewById(com.example.learn.R.id.shurumima);*/
new AlertDialog.Builder(MainActivity.this).setTitle("请先登录").setView(com.example.learn.R.layout.dierge).setNegativeButton
("登录", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
LinearLayout lin=(LinearLayout)getLayoutInflater().inflate(com.example.learn.R.layout.dierge, null);
EditText yong=(EditText) lin.findViewById(com.example.learn.R.id.shuruyonghuming);
EditText mi=(EditText) lin.findViewById(com.example.learn.R.id.shurumima);
Log.i("tag", "用户名是:"+yong.getText().toString());
Log.i("tag", "密码是:"+mi.getText().toString());


}
}).show();

}
红字部分输出的总是空值,就是EditText的初始值