views:

54

answers:

2

Hi, in my Android app I've got two activities, lets say A and B. A is the main activity, and it calls Activity B like so:

Intent myIntent = new Intent(getBaseContext(), B.class);
A.this.startActivity(myIntent);

And this works fine. The back button on the phone works to return to activity A, but I want to put a button on the UI as well. So I have a "Cancel" button in Activity B's layout file, and I have the following code in Activity B's java.

public void onClick(View arg0) {

    if (arg0.getId() == R.id.btn_cancel) {
        B.this.finish();
    }

}

However, clicking the button doesn't cause anything to happen at all. Any insight? Thanks a ton!

A: 

arg0.getId() is clearly not equal to R.id.byn_cancel
just remove the if statement and only include B.this.finish();

binnyb
A: 

Try to see if the button is actually working first.

Try with a simple Log.d(); and see if that outputs something in the lolcat

IvanSF