Я расширил диалог, чтобы создать всплывающее окно с текстом редактирования. Я планирую использовать это всплывающее окно в нескольких местах в моем коде. Я хочу установить текст редактирования, когда всплывающее окно открывается из класса, который он открывает
Проблема у меня есть метод settext дает нулевой указатель
public class RoundCommentDialog extends Dialog implements View.OnClickListener {
private Context context;
private String roundCommentText;
private EditText roundCommentEditText;
private Button postiveButton;
private Button negativeButton;
public RoundCommentDialog(Context context) {
super(context);
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_round_comment_dialog);
postiveButton = (Button) findViewById(R.id.dialog_positive_button);
postiveButton.setOnClickListener (this);
negativeButton = (Button) findViewById(R.id.dialog_negative_button);
negativeButton.setOnClickListener (this);
roundCommentEditText = (EditText) findViewById(R.id.comment_text);
}
public void setRoundCommentText(String roundCommentText) {
this.roundCommentText = roundCommentText;
}
public String getRoundCommentText() {
return roundCommentEditText.getText().toString();
}
public void updateCommentEditField() {
roundCommentEditText.setText("TEST");
}
public Dialog getDialog() {
updateCommentEditField();
return this;
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.dialog_positive_button:
setRoundCommentText(roundCommentText);
dismiss();
break;
case R.id.dialog_negative_button:
cancel();
break;
}
}
}
из класса, из которого я его вызываю, я создаю новую версию класса, затем вызываю метод setRoundComment (test), а затем метод show. это дает нулевой указатель
Спасибо за ваше время
Editted
Baisiclly Я звоню выше класс из основного класса
RoundCommentDialog myDialog = new RoundCommentDialog(this);
Затем я выполняю следующие действия на приемнике кнопок
myDialog.setRoundCommentText(roundComentText);
myDialog.getDialog().show();
В случае ошибок возникает ошибка, когда я вызываю GetDialog (), а в классе диалога это ошибка в следующей строке
roundCommentEditText.setText("TEST");