Question

I want to set webpage URL from dialog which will load URL on mainActivity WebView Let me describe what I want. When I open application, the dialog will pop up and u have to set URL and then just will load the URL in WebView. In second Choice I want that same dialog open from menu item.

No correct solution

OTHER TIPS

Create an XML Layout that contain a webview called webview.xml in your layout folder as following:

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

In your Activity onCreate method add the following initialization and data setting

private WebView webView;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview);

    webView = (WebView) findViewById(R.id.webView1);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl("http://www.google.com");
    //Replace the previous URL with the one that you want to open
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top