【发布时间】:2021-04-14 09:07:55
【问题描述】:
我的对话框中需要几个编辑文本,我通常在 xml 中添加它们,但打开时它们会消失这是我的代码:
public class SubmissionDialog extends AppCompatDialogFragment {
private TextProcessor tpCode;
private EditText etOutput;
private EditText etExpectedOutput;
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.view_submission_dialog, null);
Bundle bundle = this.getArguments();
builder.setView(view)
.setTitle("Task submission.")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// nothing
}
});
tpCode = (TextProcessor) view.findViewById(R.id.tpCodeDialog);
etOutput = (EditText) view.findViewById(R.id.etDialogOutput);
etExpectedOutput = (EditText) view.findViewById(R.id.etDialogExpectedOutput);
tpCode.setTextContent(bundle.getString("code"));
tpCode.setLanguage(new JavaLanguage());
tpCode.setColorScheme(EditorTheme.INSTANCE.getMONOKAI());
etOutput.setText(bundle.getString("output"));
etExpectedOutput.setText(bundle.getString("expectedOutput"));
return builder.create();
}
}
这特别奇怪,因为我做了很多次,但只是这次它消失了,我检查 bundle 不是空的,在我的 xml 中也没有错误。
【问题讨论】:
-
你是否使用了匹配约束的高度元素的约束布局
-
@devfoFikiCar 是在编辑文本部分
标签: android android-studio user-interface android-edittext