Saturday, January 12, 2013

prevent the activity from loading twice


In the button's event listener, disable the button and show another activity.
    Button b = (Button) view;
    b.setEnabled(false);

    Intent i = new Intent(this, AnotherActitivty.class);
    startActivity(i);
Override onResume() to re-enable the button.
@Override
    protected void onResume() {
        super.onResume();

        Button button1 = (Button) findViewById(R.id.button1);
        button1.setEnabled(true);
    }

No comments:

Post a Comment