0
I have this AlertDialog
that shows on the other screen layout , in that layout has several EditText
and a Button
. How can I get the sword text of each of the edittext
when I click on ok
or the button on the layout that will appear in the AlertDialog
. I tried to do with LayoutInflanter
but I couldn’t. Look:
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();