This is my dialog inside fragment it works fine, now I want that when i click "ok" button it reload the current fragment. the dialog is show when the method showDialog is called: mi fragment is android.support.v4.app.Fragment
void showDialog() {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View promptView = layoutInflater.inflate(R.layout.dialog_fragment_agenda, null);
TextView txtNombre = (TextView)promptView.findViewById(R.id.txtdialog1);
txtNombre.setText("ADD THIS STUFF?");
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getContext());
alertDialogBuilder.setView(promptView);
alertDialogBuilder.setPositiveButton("Ok",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
sendSomeStuff();
//HERE TODO RELOAD OR REFRESH THE FRAGMENT
}
});
alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
} });
AlertDialog alert = alertDialogBuilder.create();
alert.show();
}
update this is the fragment. Iwant to recall the onCreateView methos of the fragment
public class FragmentOne extends Fragment {
//...some variables
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_one, container, false);
showDialog()//HERE I CALL MY CUSTOM DIALOG
return rootView;
}
}
The Simple Solution
Tested using viewpager, and FragmentPagerAdapter
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.detach(FragmentOne.this).attach(FragmentOne.this).commit();