avast / android-styled-dialogs

Backport of Material dialogs with easy-to-use API based on DialogFragment
Apache License 2.0
2.15k stars 450 forks source link

Custom WebView - not displayed #75

Closed CannyDuck closed 9 years ago

CannyDuck commented 10 years ago

I try to create a custom WebView instead of a simple message as Dialog content:

@Override
public BaseDialogFragment.Builder build(BaseDialogFragment.Builder builder) {
            WebView wv = new WebView(getActivity());
            wv.loadData("<html><body><h1>Hello World!</h1></body></html>", "text/html", "UTF-8");

            builder.setTitle(getActivity().getResources().getString(full ? R.string.changelog_full_title : R.string.changelog_title))
                    .setView(wv)
                    .setPositiveButton(getActivity().getResources().getString(R.string.changelog_ok_button), new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            dismiss();
                        }
                    });
            return builder;
        }

Unfortunately the WebView ist not displayed? What I am doing wrong? Try the code from your demo using an image as custom view works as expected.

davidvavra commented 9 years ago

You don't set any layout parameters to the WebView. I suggest creating a xml layout for the WebView.