Я очень новичок в Java, и я стараюсь, чтобы все было просто. Почему это не работает? У меня есть XML-макет с полем EditText
и Submit Button
. Я хочу нажать его, AlertDialog
, чтобы выскочить с TextView
того, что я ввел в EditText
. То, что я попробовал, продолжает сбой:отправить EditText и показать результат в AlertDialog TextView
//CustomAlertDialogPopUp
public void submitButton(View v) {
LayoutInflater inflater = getLayoutInflater();
View alertLayout = inflater.inflate(R.layout.alertXML, null);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Alert");
alert.setView(alertLayout);
AlertDialog dialog = alert.create();
dialog.show();
EditText text1 = (EditText)findViewById(R.id.inputText);
TextView text2 = (TextView)findViewById(R.id.alertText);
String result = text1.getText().toString();
text2.setText(result);
}
Извините, если я говорю глупо! Как я уже сказал, супер новый.
Что такое выход LogCat? Мы не можем понять, почему он сбой – basic
EditText text1 = (EditText) ** alertLayout **. FindViewById (R.id.inputText); –