-1
我想調用不同的充URL
l當從水平到垂直方向的變化意味着不同URL
來回浴佈局我該怎麼辦呢?..Android的web視圖調用不同的URL時,方向改變
public class MainActivity extends Activity {
//private static final String URL = "http://indiqo.eu/demos/storefront-mobile/";
private static final String URL = "file:///android_asset/index.html";
private WebView mWebView;
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
//mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
final Activity activity = this;
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
activity.setProgress(progress * 1000);
}
});
//refreshWebView();
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE))
.getDefaultDisplay();
int orientation = display.getRotation();
if (orientation == Surface.ROTATION_90
|| orientation == Surface.ROTATION_270) {
mWebView.loadUrl(URL);
} else {
mWebView.loadUrl(URL);
}
}
@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
}
}
在哪裏寫代碼? – mydeve 2014-11-24 12:14:14
無論你在哪裏設置你的URL參數 – markt 2014-11-24 12:17:06
出錯? – mydeve 2014-11-24 12:17:48