WebView mWebView=(WebView) findViewById(R.id.webView1);
mWebView.loadUrl("http://www.yuneach.com");在模拟器上,这个网页是在我自己的Activity上显示的,但是我把应用安装到手机上时,却弹出选择浏览器,然后是浏览器中显示了网页(脱离了我的Activity),请问这个怎么回事?

解决方案 »

  1.   

    你的是默认使用的是手机自带的浏览器打开看下面这个↓
        public void onCreate(Bundle savedInstanceState) { 
             super.onCreate(savedInstanceState); 
             setContentView(R.layout.main); 
             // get the view web intent 
             Intent intent = this.getViewWebIntent(); 
             this.printInterestedActivitiesByIntent(intent); 
             // set the className to use the specific browser to open the webpage. 
             intent.setClassName("com.tencent.mtt", "com.tencent.mtt.MainActivity"); 
             startActivity(intent); 
         } 
      
      
         /*
          *get the desired view web intent 
          */ 
         private Intent getViewWebIntent() { 
             Intent viewWebIntent = new Intent(Intent.ACTION_VIEW); 
             Uri uri = Uri.parse("http://www.2cto.com"); 
     
            viewWebIntent.setData(uri); 
             return viewWebIntent; 
         } 
      

  2.   

    怎么才能在手机上也能在我的Activity中显示网页?
      

  3.   

    楼主,我今天在softreg.com.cn付款购买了你的软件,请发注册码到我信箱,谢谢
    定 单 号:6795224
      

  4.   

    mWebView1 是自己定义的webView控件,加个方法就行。url是你的初始地址,之后每次点击都是在你的Activity中跳转而不会打开浏览器
    mWebView1.setWebViewClient(new WebViewClient()
        {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url)
          {        view.loadUrl(url); // 在当前的webview中跳转到新的url        return true;
          }
        });
      

  5.   

    请问是这样写吗?public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        WebView mWebView=(WebView) findViewById(R.id.webView1);
        mWebView.setWebViewClient(new WebViewClient()
       {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url)
          {         view.loadUrl("http://localhost"); // 在当前的webview中跳转到新的url         return true;
          }
        });    mWebView.loadUrl("http://localhost");
    }
      

  6.   

    Android系统防止browser新开链接,必须覆盖WebView的WebViewClient对象!