title: Android: why can't I call setOnClickListener method on a button outside of an onCreate method?
body: <p>This is a newbie question but why can't I call setOnClickListener method on a button outside of an onCreate method?</p>
  
  <p>For example why can't I do this? Or maybe Eclipse just don't have setOnClickListener code hinting outside of onCreate method? Cause nothing shows up.</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main_layout);
  }
  
  
  Button button = (Button) findViewById(R.id.button_send);
     button.setOnClickListener(new View.OnClickListener() {
       public void onClick(View v) {
        // Do something in response to button click
    }
  });
  </code></pre>