Use the XML layout containing Webview. Then call dialog.setContentView (R.layout.web_dialog)
After that, configure the web view as follows: WebView wv = (WebView) findViewById (R.id.webview); "R.id.webview" is the identifier in the XML layout file.
Dialog example layout:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <WebView android:id="@+id/webview" android:scrollbars="vertical" android:scrollbarAlwaysDrawVerticalTrack="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" /> </LinearLayout>
Your code has been changed:
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()); dialog.setContentView(R.layout.web_dialog) WebView wb = (WebView) dialog.findViewById(R.id.webview); wb.getSettings().setJavaScriptEnabled(true); wb.loadUrl("http://www.google.com"); wb.setWebViewClient(new HelloWebViewClient()); dialog.setCancelable(true); dialog.setTitle("WebView"); dialog.show(); } });
Natie klopper
source share