I have this AlertDialog
which shows on the screen another layout , in this layout has several EditText
and a Button
. I would like to know how I can do to get the text of each of the edittext
when I click on ok
or the button that has layout that will appear in AlertDialog
. I tried to LayoutInflanter
but could not. See:
Context context = getBaseContext();
LayoutInflater inflant = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
final LinearLayout layout = (LinearLayout) inflant.inflate(R.layout.main, null);
AlertDialog.Builder dialogo = new AlertDialog.Builder(MainActivity.this);
dialogo.setTitle("Informe o Nome");
dialogo.setView(R.layout.main);
dialogo.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface di, int e) {
ettext = (EditText) layout.findViewById(R.id.ettext);
Toast.makeText(getBaseContext(), ettext.getText(), Toast.LENGTH_SHORT).show();
}
});
dialogo.show();