title: setOnEditorActionListener not working for me
body: <p>I am just learning java/android and I have a problem with setOnEditorActionListener.</p>
  
  <p>My problem is that the first time a webpage only load from clicking on the "Go" button and not from the done button on the keyboard.  After the first time, the webpage can be loaded from the Done button on the keyboard.</p>
  
  <p>There is also a problem with onConfigurationChanged, but I will ask for help as a separate question.</p>
  
  <p>Any help or suggestions will be much appreciated.</p>
  
  <p>I would like to be able to have both buttons work all the time.</p>
  
  <p>activity_main.xml
      
  
  <pre><code> android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" &gt;
  
  
  &lt;TableRow
  android:id="@+id/tableRow1"
  andoid:layout_width="match_parent"
  android:layout_height="wrap_content" &gt;
  &lt;EditText
      android:id="@+id/UrlText"
      android:hint="Enter URL"
      android:layout_width="600px"
      android:layout_height="wrap_content"
      android:inputType="textUri"
      android:singleLine="true"
      android:lines="1"
      android:imeOptions="actionDone"&gt;
  
      &lt;requestFocus /&gt;
  
  &lt;/EditText&gt;
  &lt;Button
      android:id="@+id/button1"
      android:onClick="onClick"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="Go" /&gt;
  
  
  
  &lt;/TableRow&gt;
  &lt;WebView
  android:id="@+id/webView1"
  android:layout_width="match_parent"
  android:layout_height="match_parent" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Main_Activity.java</p>
  
  <pre><code>package com.authorwjf.kbdtoggled;
  
  import android.app.Activity;
  import android.content.Context;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.inputmethod.InputMethodManager;
  import android.webkit.WebSettings;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.view.KeyEvent;
  import android.widget.Toast;
  import android.view.inputmethod.EditorInfo;
  import android.widget.TextView.OnEditorActionListener;
  import android.content.res.Configuration;
  
  
  public class MainActivity extends Activity implements OnClickListener {
  
  
  private WebView wv;
  private InputMethodManager mIMEMgr;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mIMEMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      findViewById(R.id.button1).setOnClickListener(this);
  }
  
  @Override
  public void onClick(View v) {
   //
    // function to detect when the send button is pressed and if it is
    // get the text from the edittext box
    // then condition it to have http attributes
    // finally, close the keyboard
    //
      EditText editText = (EditText) findViewById(R.id.UrlText);
      editText.setOnEditorActionListener(new OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
              boolean handled = false;
              //
              // test to see if the send button was pressed
              //
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              //
              //  toast ouput for debugging
              //
                  Context context = getApplicationContext();
                  CharSequence text = "Hello toast!";
                  int duration = Toast.LENGTH_SHORT;
  
                  Toast toast = Toast.makeText(context, text, duration);
                  toast.show();
  
                  handled = true;
                  //
                  // hide the keyboard
                  //
                  mIMEMgr.hideSoftInputFromWindow(findViewById(R.id.UrlText).getWindowToken(), 0);
                  //
                  // now, get the id of the webview
                  //
                  wv = (WebView) findViewById(R.id.webView1);
                  //
                  // define the methods to apply to the webview
                  //
                  WebSettings settings = wv.getSettings();
                  settings.setJavaScriptEnabled(true);
                  settings.setBuiltInZoomControls(true);
                  //
                  // apply the methods to the webview client
                  //
                  wv.setWebViewClient(new MyWebViewClient());
                  //
                  // condition the url sting
                  //
                  EditText et = (EditText) findViewById(R.id.UrlText);
                  String url = et.getText().toString().trim();
                  //
                  // and now load the webpage
                  //
                  wv.loadUrl("http://" + url);
  
              }
              return handled;
          }
      });
  
  
       if (v.getId() == R.id.button1)  {
          //
          // hide the keyboard
          //
          mIMEMgr.hideSoftInputFromWindow(findViewById(R.id.UrlText).getWindowToken(), 0);
          //
          // now, get the id of the webview
          //
          wv = (WebView) findViewById(R.id.webView1);
          //
          // define the methods to apply to the webview
          //
          WebSettings settings = wv.getSettings();
          settings.setJavaScriptEnabled(true);
          settings.setBuiltInZoomControls(true);
          //
          // apply the methods to the webview client
          //
          wv.setWebViewClient(new MyWebViewClient());
          //
          // condition the url sting
          //
          EditText et = (EditText) findViewById(R.id.UrlText);
          String url = et.getText().toString().trim();
          //
          // and now load the webpage
          //
          wv.loadUrl("http://" + url);
  
           //  toast ouput for debugging
  
           Context context = getApplicationContext();
           CharSequence text = "Hello toast from onClick2";
           int duration1 = Toast.LENGTH_SHORT;
  
           Toast toast1 = Toast.makeText(context, text, duration1);
           toast1.show();
      }
    //
  }
  
  //
  // class to listen for the keyboard send button
  //
  
  
  
  
  private class MyWebViewClient extends WebViewClient {
  
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
          // TODO Auto-generated method stub
          return false;
      }
  
  }
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
   //   Configuration newConfig = getResources().getConfiguration();
      super.onConfigurationChanged(newConfig);
      Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
      // Checks the orientation of the screen
      if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
          Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
      } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
          Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.authorwjf.kbdtoggled"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="14"
      android:targetSdkVersion="21" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
  
      &lt;activity
          android:configChanges="orientation|keyboardHidden"
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
          android:windowSoftInputMode="adjustResize|stateHidden" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>