标签:des android cWeb style blog http io color ar
Google 自带
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="mirror.android.miniweb.MiniBrowser" > <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipe_contain" android:layout_width="match_parent" android:layout_height="match_parent"> <WebView android:id="@+id/web_show" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </android.support.v4.widget.SwipeRefreshLayout> </LinearLayout>
package mirror.android.miniweb; import android.app.Activity; import android.os.Bundle; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.EditText; import android.widget.Toast; public class MiniBrowser extends Activity { private WebView webView; private SwipeRefreshLayout swipeRefresh; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mini_browser); //SwipeRefresh swipeRefresh = (SwipeRefreshLayout)findViewById(R.id.swipe_contain); swipeRefresh.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { //重新加载刷新页面 webView.loadUrl(webView.getUrl()); } }); swipeRefresh.setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light); //WebView webView = (WebView)findViewById(R.id.web_show); webView.loadUrl("http://www.baidu.com"); //添加javaScript支持 webView.getSettings().setJavaScriptEnabled(true); //取消滚动条 webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); //触摸焦点起作用 webView.requestFocus(); //点击链接继续在当前browser中响应 webView.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); //设置进度条 webView.setWebChromeClient(new WebChromeClient(){ @Override public void onProgressChanged(WebView view, int newProgress) { if(newProgress == 100){ //隐藏进度条 swipeRefresh.setRefreshing(false); }else if(!swipeRefresh.isRefreshing()){ swipeRefresh.setRefreshing(true); } } }); } }
标签:des android cWeb style blog http io color ar
原文地址:http://www.cnblogs.com/iMirror/p/4070947.html