我有自定义警报对话框。当我单击自定义对话框中的文本视图时,这将关闭并打开另一个自定义对话框。但未关闭此自定义对话框。
Alert.Builder alertViewTaskDescription = new AlertDialog.Builder(
getActivity());
LayoutInflater inflaterViewTaskDescription = (LayoutInflater) getActivity()
.getSystemService(getActivity().LAYOUT_INFLATER_SERVICE);
viewTaskWithDescription = (View) inflaterViewTaskDescription
.inflate(R.layout.viewtaskwithdescriptionlayout, null,
false);
TextView textviewTask = (TextView) viewTaskWithDescription
.findViewById(R.id.taskidDaytoDayView);
TextView textviewDescription = (TextView) viewTaskWithDescription
.findViewById(R.id.descriptionidDaytoDayView);
textviewTask.setText(taskName);
textviewDescription.setText("ADD DESCRIPTION");
alertViewTaskDescription.setView(viewTaskWithDescription);
alertDialog = alertViewTaskDescription.create();
textviewDescription.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
alertDialog.cancel();
AlertDialog.Builder alertEditTaskDescription = new AlertDialog.Builder(getActivity());
LayoutInflater inflaterEditTaskDescription = (LayoutInflater) getActivity()
.getSystemService(
getActivity().LAYOUT_INFLATER_SERVICE);
View viewEditTaskDescription = (View) inflaterEditTaskDescription
.inflate(R.layout.edittaskwithdescriptionlayout,
null, false);
final EditText edittextTask = (EditText) viewEditTaskDescription
.findViewById(R.id.taskidDaytoDayEdit);
final EditText edittextDescription = (EditText) viewEditTaskDescription
.findViewById(R.id.descriptionidDaytoDayEdit);
edittextTask.setText(taskName);
edittextDescription.setText(taskDescription);
edittextTask.setSelection(edittextTask.getText()
.length());
edittextDescription
.setSelection(edittextDescription.getText()
.length());
alertEditTaskDescription
.setView(viewEditTaskDescription);
alertEditTaskDescription.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int which) {
}
});
alertViewTaskDescription.create().show();
}});