Question

I am a beginner in android development.For the application I am developing, I need a dialoge fragment with layout as specified in a xml file in res/layout.How can I achieve this.I have seen many tutorials online,but unfortunately most of them explains how to build a dialogue with yes/no buttons.But my requirement is a custom layout for DialogFragment.How can I achieve this?

Was it helpful?

Solution

Create a simple custom class and extends the dialog fragment as below. You can create your own layout and handle the view clicks.

public static class CustomDialogFragment extends DialogFragment {

   @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.custom_dialog_fragment, container, false);
    return view
 }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top