title: Adding onClick to button in dialog layout, that doesn't have class
body: <p>I have dialog layout xml file which stores button, and I have set <code>android:onClick="doSomething"</code>, but I dont have any class files attached to that dialog. So practically dialog_layout.xml is the only file that I have in my project. I am able to show it and able to interact with it, but I can't make onClick listener for the button in dialog. 
  I tried making the Activity that launches my dialog an owner of that dialog and then in that Activity create public void doSomething(View view) but it still doesnt seem to work. I get this error: </p>
  
  <pre><code>08-03 23:39:23.085: E/AndroidRuntime(6757): java.lang.IllegalStateException: Could not find a method doSomething(View) in the activity class android.view.ContextThemeWrapper for onClick handler on view class android.widget.Button with id 'button2'
  </code></pre>
  
  <p>any idea what am I doing wrong?</p>
  
  <p>EDIT
  here is the code:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.settings);
  
      findViewById(R.id.button2).setOnClickListener(new OnClickListener() {
          public void onClick(View v) {
          //Do something.
          } 
      });
  
  
  
  
      Preference keyP = (Preference) findPreference("keyP");
      keyP.setOnPreferenceClickListener(new OnPreferenceClickListener() {
          public boolean onPreferenceClick(Preference preference) {
  
  
  
              Dialog dialog = new Dialog(SettingsActivity.this);
              dialog.setContentView(R.layout.draws_dialog);
              dialog.setTitle("Title");
              dialog.show();
  
              return true;
          }
      });
  </code></pre>