Quando eu aperto o botão voltar do smartphone ele volta para activity anterior e não para a outra página da Web view.
MEU código da Weba.Java é esse;
package coa.examplea.myaplicationa;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.myapplication.R;
public class Weba extends Activity {
private WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.web);
WebView webview=(WebView)findViewById(R.id.webView);
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webview.setWebViewClient(new MyCustomWebViewClient());
webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webview.loadUrl("http://...");
}
private class MyCustomWebViewClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
Eu já tentei colocar
@Override
public void onBackPressed() {
if (webview.canGoBack()) {
webview.goBack();
} else {
finish( );
}
}
Mas ocorre Erro quando eu aperto o botão voltar.