你好,我是新来的android和我写了一个“简单的网络浏览器”的小应用程序。 但我的浏览器无法打开页面,它显示错误,如没有网络可用(网页不可用)甚至无线开启,并且正常的浏览器正在该设备上工作。Android浏览器无法打开网页
请检查下面的代码:: SimpleBrowser.java
package com.thenewboston.travis;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
public class SimpleBrowser extends Activity implements OnClickListener{
Button bGo,bBack,bForward,bHistory,bRefresh;
EditText et;
WebView wb;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.simplebrowser);
bGo = (Button)findViewById(R.id.go);
bBack = (Button)findViewById(R.id.bBack);
bForward = (Button)findViewById(R.id.bForward);
bHistory = (Button)findViewById(R.id.bHistory);
bRefresh = (Button)findViewById(R.id.bRefresh);
et = (EditText)findViewById(R.id.editAddress);
wb = (WebView)findViewById(R.id.webView);
wb.setWebViewClient(new ourViewClient());
bGo.setOnClickListener(this);
bBack.setOnClickListener(this);
bForward.setOnClickListener(this);
bHistory.setOnClickListener(this);
bRefresh.setOnClickListener(this);
//wb.loadUrl("http://www.gmail.com");
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(arg0.getId())
{
case R.id.go:
String website = et.getText().toString();
wb.loadUrl(website);
break;
case R.id.bBack:
if(wb.canGoBack())
wb.goBack();
break;
case R.id.bForward:
if(wb.canGoForward())
wb.goForward();
break;
case R.id.bHistory:
wb.clearHistory();
break;
case R.id.bRefresh:
wb.reload();
break;
}
}
}
ourViewClient.java
package com.thenewboston.travis;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class ourViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}
}
和.... 的Manifest.xml
package="com.thenewboston.travis"
android:versionCode="1"
android:versionName="1.0" >
android:minSdkVersion="10"
android:targetSdkVersion="17" />
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="KCRaju"
android:theme="@style/AppTheme">
android:name="com.thenewboston.travis.Splash"
android:label="KCRaju"
android:screenOrientation="portrait" >
android:name=".StartingPoint"
android:label="KCRaju" >
android:name=".Menu"
android:label="KCRaju" >
android:name=".prefs"
android:label="KCRaju" >
android:name=".About"
android:label="KCRaju"
android:theme="@android:style/Theme.Dialog" >