想知道如何让 webview 回去。
尝试将 webview 重新放在新闻上,但似乎我的代码无法正常工作。不知道我是否发起了它,仍然对此感到困惑。
是否有可能摆脱 webview 中的滚动条?我发现了一些关于它的帖子,但我仍然对如何将它放入我的代码中
package com.webapp.area956;
import android.os.Bundle;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.Menu;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebViewClient yourWebClient = new WebViewClient()
{
// Override page so it's load on my view only
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
// This line we let me load only pages inside Firstdroid Webpage
if ( url.contains("area956") == true )
// Load new URL Don't override URL Link
return false;
// Return true to override url loading (In this case do nothing).
return true;
}
};
String url = "http://www.area956.com";
WebView view = (WebView) this.findViewById(R.id.webView1);
view.setWebViewClient(yourWebClient);
view.getSettings().setJavaScriptEnabled(true);
view.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
view.loadUrl(url);
}
public void onBackPressed (){
if (WebView.canGoBack()) {
WebView.goBack();
}
else {
super.onBackPressed();
finish();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}