//示例地图类

packagecom.can2do.doimobile.news;importandroid.os.Bundle;importandroid.os.Handler;importandroid.os.Message;importandroid.webkit.WebView;importandroid.webkit.WebViewClient;importandroid.widget.TextView;importcom.can2do.doimobile.R;importcom.can2do.doimobile.base.BaseUiWeb;importcom.can2do.doimobile.base.C;public class UiNewsOne extendsBaseUiWeb {private String tag = null;privateWebView mWebViewMap;

@Overridepublic voidonStart() {super.onStart();

setContentView(R.layout.ui_news_one);

Bundle params= this.getIntent().getExtras();

tag= params.getString("tag");

TextView titleText= (TextView) this.findViewById(R.id.main_top_title1);

titleText.setText(tag);

mWebViewMap=(WebView) findViewById(R.id.web_news_one);

mWebViewMap.getSettings().setJavaScriptEnabled(true);

mWebViewMap.setWebViewClient(newWebViewClient(){

});

mWebViewMap.setWebViewClient(newWebViewClient() {public void onReceivedError(WebView view, interrorCode, String description, String failingUrl)

{

view.stopLoading();

view.clearView();

Message msg=handler.obtainMessage();//发送通知,加入线程

msg.what=1;//通知加载自定义404页面

handler.sendMessage(msg);//通知发送!

}public booleanshouldOverrideUrlLoading(WebView view, String url)

{

view.loadUrl(url);return true;

}

});

mWebViewMap.loadUrl(C.news.news1);this.setWebView(mWebViewMap);this.startWebView();

}protected Handler handler = newHandler(){public voidhandleMessage(Message message){switch(message.what) {case 1:

mWebViewMap.loadUrl("file:///android_asset/www/404/404.html");break;

}

}

};

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐