Custom Dialogs in android using DialogFragment:
DialogFragment is the fragment that shows dialog window on top of your activity.
We have to override DialogFragment class and implement onCreateView(LayoutInflater, ViewGroup, Bundle) to use the content of the dialog.
I am showing listview on this dialog window.
public class DFragment extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.custom_dialog_flag, container,
false);
FlagAdapter flagAdapter = new FlagAdapter(RegisterationMedVisitDoctor.this, flagList);
listViewCountryFlags =(ListView) rootView.findViewById(R.id.list_view_country_flags);
listViewCountryFlags.setAdapter(flagAdapter);
getDialog().setTitle("Select Country");
listViewCountryFlags.setAdapter(flagAdapter);
// Do something else
return rootView;
}
}
and call this class from specified position
DFragment dFragment = new DFragment();
dFragment.show(getFragmentManager(), "Alert Dialog");
0 Comment(s)