大家都知道Android可以加载网页,但是网上给的一些例子都是html的,所以最近有被误导到,再次分享一下心得。

如果是加载你自己网站或是空间上的网页时,不要直接加载html格式的,因为当你更换html内容时(地址不变),Android显示的还是你没有更改之前的html。所以要想实现动态的更改网页内容,你需要使用web服务器来提供动态网页技术,比如jsp,asp之类的。送给需要的朋友。

这下终于理解动态网页和静态网页的一些区别了,回头要好好补一下这方面的知识了。

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.Toast;


public class UnicomActivity extends Activity {

WebView webView;
private static final String URL = "http://60.18.151.202/android.asp"; //不是html哦
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// 进行全屏

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
webView=(WebView) findViewById(R.id.webView01);

webView.loadUrl(URL);
}


@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
dialog();
return true;
}
return true;
}
protected void dialog() {
AlertDialog.Builder builder = new Builder( UnicomActivity.this);
builder.setMessage("确定要退出吗?");
builder.setTitle("提示");
builder.setPositiveButton("确认",
new android.content.DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
//AccoutList.this.finish();
//System.exit(1);
android.os.Process.killProcess(android.os.Process.myPid());
}
});
builder.setNegativeButton("取消",
new android.content.DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
}


更多相关文章

  1. Android布局优化之ViewStub、include、merge使用与源码分析
  2. Android(安卓)入门第八讲01-WebView(WebView概述,基本用法(加载远程
  3. 什么?Android遇到瓶颈了?
  4. Android中ListView如何分页加载数据
  5. Android中利用“反射”动态加载R文件中的资源
  6. 动态更改屏幕方向的简单例子(LANDSCAPE与PORTRAIT)!
  7. android 系统System UI Tuner大概讲解
  8. 关于android 根据系统语言更改 app名字和其他配置
  9. android volley解析与二次封装

随机推荐

  1. android 布局文件 layout_weight用法
  2. Android 如何使用浏览器去下载app和加载h
  3. android process bar 几种style
  4. Android(安卓)初始化Setup Wizard——Pro
  5. Android Frameworks系列之IMF(一)
  6. 【Android文档】Android界面绘制流程----
  7. android中搭建phonegap开发环境
  8. xmlns:android作用以及自定义布局属性
  9. Android核心技术与实例详解(第2版)
  10. Android源码树添加新的APP(含第三方so、ja