Android Dialog(对话框中获取输入框的内容) ,直接上代码
[java]
final EditText et = new EditText(this); et.setText(mSharedPreferences.getString("ipadd", "127.0.0.1")); //获取ip而已,不用在乎 new AlertDialog.Builder(this).setTitle("请输入IP地址") .setIcon(android.R.drawable.ic_dialog_info).setView(et) .setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { //数据获取 //Toast.makeText(TestTabActivity.this, et.getText().toString(), // Toast.LENGTH_LONG).show(); mEditor.putString("ipadd", et.getText().toString()); //关键在这儿,获取输入框的数据,原来很简单!! mEditor.commit(); } }).setNegativeButton("取消", null).show();