在android中加载两个webview

时间:2012-04-18 06:58:00

标签: android url android-activity webview

我有要求我需要在webview中加载网址并点击该网页视图中的按钮,我必须打开一个新的网页视图。

我已经为它编写了以下代码,但它不会引发任何异常,无论是加载新页面/ webview。

我必须使用单一活动。如果您有任何想法,请提供解决方案。

public class WebScreen extends Activity{  
    public static final String URL = null;  
    NewWebview mWebView=null;  
    WebView webView=null;  

     /** Called when the activity is first created. */  
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.webscreen);  

        String url = getIntent().getExtras().getString("URL");  
        Log.i("URLLL",url);  
        webView = new WebView(this);              
        webView.loadUrl(url);  

        mWebView = new NewWebview(this);  

    }  
}  

public class NewWebview {  

    private Context context;  

    public NewWebview(Context context) {  
        // TODO Auto-generated constructor stub  
        Log.i("","New webViewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww");  
        this.context=context;  
        WebView webView=new WebView(context);  
        ((Activity)context).setContentView(R.layout.webscreen);  
        webView.loadUrl("www.google.com");

    }  
}  

感谢
斯纳

0 个答案:

没有答案