-
- // 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
- 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();
- }
- return true;
- }
- // Do not consume the event.
- return false;
- }
- });
-