I am trying to load web view in to dialog. I am usuing the following code.
final TextView seeMonthlyBill = (TextView) parentLayout
.findViewById(R.id.my_ac_my_service_timewarnercable_link);
seeMonthlyBill.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Dialog dialog = new Dialog(getActivity());
WebView wb = new WebView(getActivity());
wb.getSettings().setJavaScriptEnabled(true);
wb.loadUrl("http://www.google.com");
wb.setWebViewClient(new HelloWebViewClient());
dialog.setCancelable(true);
dialog.setContentView(wb);
dialog.setTitle("WebView");
dialog.show();
}
});
I want to open web view on the click on a text view. When i am clicking on the text view dialog is opening without the webview. Can any please help me to solve this issue.
Thanks in advance.
Use a XML layout containing a Webview.
Then call dialog.setContentView(R.layout.web_dialog)
Set up the webview afterwards like so:
WebView wv = (WebView) findViewById(R.id.webview);
“R.id.webview” being the ID in the XML Layout file.
Dialog Layout example:
Your code modified: