I created a custom dialog and I\'d like to start a new activity when OK is clicked. How can I get the context to set it as first argument of my Intent constructor?
I
public class CustomDialog extends Dialog implements OnClickListener {
Button okButton, cancelButton;
Activity mActivity;
public CustomDialog(Activity activity) {
super(activity);
mActivity = activity;
setContentView(R.layout.custom_dialog);
okButton = (Button) findViewById(R.id.button_ok);
okButton.setOnClickListener(this);
cancelButton = (Button) findViewById(R.id.button_cancel);
cancelButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == cancelButton)
dismiss();
else {
Intent i = new Intent(mActivity, ItemSelection.class);
mActivity.startActivity(i);
}
}
}