Xyro
Xyro

Reputation: 227

Android finish error

Just started with some basic android development and I made a little menu with 3 buttons.

One of them is a quit button (I know that the finish activity doesn't really quit the application) but when I call it it closes the application and gives me a error saying that the application has stopped unexpectedly.

My code :

package darksea.game;

import android.app.Activity;
import android.os.Bundle;

public class DarkSeaActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    public void ExitGameEvent()
    {
        finish();
    }
}

The ExitGameEvent is linked to the button through xml.

Any thought on why it gives this error ?

Upvotes: 1

Views: 1082

Answers (1)

antonyt
antonyt

Reputation: 21883

Your click handler needs to take a View as an argument for it to be valid to be called from XML. Try:

public void ExitGameEvent(View v)
    {
        finish();
    }

Upvotes: 1

Related Questions