If anyone can help me with this I will be very happy. I have an application that uses webview. The webview loads a url and I have used the Google tutorial to overide all the other links that I want to open with webview also. I have create an animimation file in res/
and a slide_right xml
and so far so good. I call the effect in my main java activity but it only applies to the first page. The thing that I want is the effect to apply in every page that links loads in webview.
Can you help my with my code?
package com.ihome;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class IhomeActivity extends Activity {
WebView mWebView;
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Animation slideRightAnimation = AnimationUtils.loadAnimation(getBaseContext (), R.anim.slide_right);
mWebView.startAnimation(slideRightAnimation);
view.loadUrl(url);
return true;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
Animation slideLeftAnimation = AnimationUtils.loadAnimation(getBaseContext (), R.anim.slide_left);
mWebView.startAnimation(slideLeftAnimation);
mWebView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com/");
mWebView.setWebViewClient(new HelloWebViewClient());