Android 带输入框的弹出框

2014-05-24 09:03

    final EditText inputServer = new EditText(this);

       AlertDialog.Builder builder = new AlertDialog.Builder(this);

       builder.setTitle("Server").setIcon(android.R.drawable.ic_dialog_info).setView(inputServer)

               .setNegativeButton("Cancel", null);

       builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {


           public void onClick(DialogInterface dialog, int which) {

              inputServer.getText().toString();

            }

       });

       builder.show();


OR


见SDK自带的源代码Api Demos里的:


App -> Dialog -> Text Entry dialog

^