+
+ // Set the favorite icon when it changes.
+ @Override
+ public void onReceivedIcon(WebView view, Bitmap icon) {
+ favoriteIcon.setImageBitmap(icon);
+ }
+ });
+
+ // Set the "go" button on the keyboard to load the URL.
+ urlTextBox.setOnKeyListener(new View.OnKeyListener() {
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+
+ // If the event is a key-down event on the "enter" button, load the URL.
+ if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
+ (keyCode == KeyEvent.KEYCODE_ENTER)) {
+ // Load the URL into the mainWebView and consume the event.
+ try {
+ loadUrlFromTextBox(mainWebView);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ // If the enter key was pressed, consume the event.
+ return true;
+ }
+ // If any other key was pressed, do not consume the event.
+ return false;
+ }