I am building an android application where on click of add button an viewdailog box is open an in there is an fom fill by the user.
I need is that on click of ok button of that viewdailog box my fragment should be reloaded as user has added the vaules.
Here is the method that I am using in viewDialog box - \
private void viewCategory() {
AlertDialog.Builder viewDialog = new AlertDialog.Builder(getActivity());
viewDialog.setTitle("add");
LayoutInflater li = (LayoutInflater)
getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = li.inflate(R.layout.customealertdialogbox1, null);
viewDialog.setView(dialogView);
viewDialog.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
name = edt1.getText().toString();
address = edt2.getText().toString();
city = edt3.getText().toString();
phone = edt4.getText().toString();
//Toast.makeText(getActivity(), name, Toast.LENGTH_SHORT).show();
new DownloadJSON().execute();
}
});
viewDialog.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
viewDialog.show();
edt1 = (EditText) dialogView.findViewById(R.id.editbox1);
edt2 = (EditText) dialogView.findViewById(R.id.editbox2);
edt3 = (EditText) dialogView.findViewById(R.id.editbox3);
edt4 = (EditText) dialogView.findViewById(R.id.editbox4);
}
Copyright Notice:Content Author:「Test123」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/26966801/reload-the-fragment-in-android