title: Android View.OnKeyListener: click once, execute twice
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3802887/public-boolean-onkey-called-twice">public boolean onKey() called twice?</a>  </p>
  </blockquote>
  
  
  
  <p>Here is my code</p>
  
  <pre><code>public class TestKeyActivity extends Activity {
  
  private int i=1;
  private ScrollView sv;
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
  
      sv=(ScrollView) this.findViewById(R.id.read_scrollView);
  
      sv.setOnKeyListener(new View.OnKeyListener() {
  
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
              if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
  
          Toast.makeText(TestKeyActivity.this, "what is wrong！！！！"+(i++), 2).show();
              return true;
              }
              return false;
          }
      });
      }
  }
  </code></pre>
  
  <p>I use he Android emulator and Eclipse，I don't know why, but when I click the key once, the code
  of toast will execute twice.
  Is there something wrong with my code?</p>