webview loadUrl 显示“找不到网页”

Android 码拜 9年前 (2015-10-22) 1301次浏览
MainActivity.java源码:
public class MainActivity extends ActionBarActivity {
private EditText metAddress;
private WebView mWebview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
metAddress = (EditText)findViewById(R.id.etAddress);
mWebview = (WebView)findViewById(R.id.webview);
mWebview.getSettings().setJavaScriptEnabled(true);
Button btnBrowse = (Button)findViewById(R.id.btnSearch);
btnBrowse.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
String address = metAddress.getText().toString();
if (URLUtil.isNetworkUrl(address)) {
mWebview.loadUrl(address);
} else {
Toast.makeText(getApplicationContext(), “请输入正确的网址.”, Toast.LENGTH_LONG).show();
}
}
});
}
AndroidManifest.xml源码:
<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
package=”heproj.h1″ >
<application
android:allowBackup=”true”
android:icon=”@drawable/ic_launcher”
android:label=”@string/app_name”
android:theme=”@style/AppTheme” >
<activity
android:name=”heproj.h1.MainActivity”
android:label=”@string/app_name” >
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
</application>
<uses-permission android:name=”andorid.permission.INTERNET”/>
</manifest>
点击按钮时总是显示“找不到网页”,不知为何?
解决方案:25分
网络访问权限开了吗

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明webview loadUrl 显示“找不到网页”
喜欢 (0)
[1034331897@qq.com]
分享 (0)