title: Android SDK (Eclipse) : How To Use SetOnKeyListener with Button?
body: <p>I just don't know how to do it. The Code is so confusing for me. Can anyone please show me the code with explanation?</p>
  
  <p>What I want is to assign enter keyCode to the <code>btn</code> button, so when user touches <em>Enter SoftKey</em>, the toast will show up just like clicking the button!</p>
  
  <p><strong>Here is The Simple App to use the code :</strong></p>
  
  <pre><code>public class MainActivity extends Activity {
  
  @Override
  
  protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_main);
  
    Button b = (Button) findViewById(R.id.btn);
  
  
    b.setOnClickListener(new View.OnClickListener() {
  
  
  @Override
  
  public void onClick(View v) {
  
      // TODO Auto-generated method stub
  
      Toast.makeText(MainActivity.this, "Hello World", Toast.LENGTH_SHORT).show();
  
  }
  
      });
  
  }
  
  @Override
  
  public boolean onCreateOptionsMenu(Menu menu) {
  
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
      }
  </code></pre>
  
  <p><strong>Please Explain it to me don't Just Write it , I'm New to Android , thanks for your Time</strong></p>