Raise a Toast : Toast « UI « Android






Raise a Toast

  
package app.test;

import android.app.Activity;
import android.os.Bundle;
import android.net.Uri;
import android.text.TextUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class Test extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    WebView webview = new WebView(this);
    webview.getSettings().setJavaScriptEnabled(true);
    // Add a client to the view
    webview.setWebViewClient(mClient);
    webview.loadUrl("http://www.google.com");
    setContentView(webview);
  }

  private WebViewClient mClient = new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      Uri request = Uri.parse(url);

      if (TextUtils.equals(request.getAuthority(), "www.google.com")) {
        // Allow the load
        return false;
      }

      Toast.makeText(Test.this, "Sorry, buddy", Toast.LENGTH_SHORT)
          .show();
      return true;
    }
  };
}
/*<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
<form name="input" action="form.html" method="get">
Enter Email: <input type="text" id="emailAddress" />
<input type="submit" value="Submit" />
</form>
</html>*/

   
    
  








Related examples in the same category

1.Toast Message Demo
2.Using Toast.LENGTH_SHORT
3.Toast and Notification, vibrate and sound
4.Show Toast
5.Make Toast Text
6.Responsible for sending Toasts under all circumstances.
7.Toast.LENGTH_SHORT
8.AlertDialog vs Toast
9.Show long,short Toast
10.The Toast util class
11.show Toast in a Thread
12.Popup Debug Message