Android popup 输入文本框
Button btnManual = (Button) findViewById(R.id.btnManual); btnManual.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(ResultActivity.this); alertDialog.setTitle("Ticket number"); alertDialog.setMessage("Enter ticket number"); final EditText txtManualTicketNo = new EditText(ResultActivity.this); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); txtManualTicketNo.setLayoutParams(lp); alertDialog.setView(txtManualTicketNo); //alertDialog.setIcon(R.drawable.); alertDialog.setPositiveButton("Validate", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { EditText scanningText = (EditText) findViewById(R.id.txtTicketScanningInfo); scanningText.setText(txtManualTicketNo.getText()); validate(); } }); alertDialog.setNegativeButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); } });