I need help saving saving the current view of the activity.
What I mean by that is than when the user clicks the back button and then comes back, I want the button that they clicked to remain unchanged and disable the buttons.
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;
public class Question1 extends ActionBarActivity {
Button Pluto, Jupiter, Earth, Mars, Doom;
TextView Points, Dooms;
@Override
final protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_question1);
Pluto = (Button) findViewById(R.id.btnPluto);
Jupiter = (Button) findViewById(R.id.btnJupiter);
Earth = (Button) findViewById(R.id.btnEarth);
Mars = (Button) findViewById(R.id.btnMars);
Doom = (Button) findViewById(R.id.btnDoom);
Points = (TextView) findViewById(R.id.txtPoints);
Dooms = (TextView) findViewById(R.id.txtDooms);
final Animation FadeIn = AnimationUtils.loadAnimation(this, R.anim.fadein);
final Animation FadeOut = AnimationUtils.loadAnimation(this, R.anim.fadeout);
Pluto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), Checkpoint.class);
startActivity(i);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
Pluto.startAnimation(FadeIn);
Pluto.setEnabled(false);
Pluto.setTextColor(Color.RED);
Jupiter.startAnimation(FadeIn);
Jupiter.setEnabled(false);
Jupiter.setTextColor(Color.GREEN);
Mars.startAnimation(FadeIn);
Mars.setEnabled(false);
Mars.setTextColor(Color.RED);
Earth.startAnimation(FadeIn);
Earth.setEnabled(false);
Earth.setTextColor(Color.RED);
}
});
Jupiter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), Checkpoint.class);
startActivity(i);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
Jupiter.setEnabled(false);
Jupiter.setTextColor(Color.GREEN);
Pluto.startAnimation(FadeIn);
Pluto.setEnabled(false);
Pluto.setTextColor(Color.RED);
Mars.startAnimation(FadeIn);
Mars.setEnabled(false);
Mars.setTextColor(Color.RED);
Earth.startAnimation(FadeIn);
Earth.setEnabled(false);
Earth.setTextColor(Color.RED);
}
});
Earth.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), Checkpoint.class);
startActivity(i);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
Pluto.startAnimation(FadeIn);
Pluto.setEnabled(false);
Pluto.setTextColor(Color.RED);
Jupiter.startAnimation(FadeIn);
Jupiter.setEnabled(false);
Jupiter.setTextColor(Color.GREEN);
Mars.startAnimation(FadeIn);
Mars.setEnabled(false);
Mars.setTextColor(Color.RED);
Earth.startAnimation(FadeIn);
Earth.setEnabled(false);
Earth.setTextColor(Color.RED);
}
});
Mars.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), Checkpoint.class);
startActivity(i);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
Pluto.startAnimation(FadeIn);
Pluto.setEnabled(false);
Pluto.setTextColor(Color.RED);
Jupiter.startAnimation(FadeIn);
Jupiter.setEnabled(false);
Jupiter.setTextColor(Color.GREEN);
Mars.startAnimation(FadeIn);
Mars.setEnabled(false);
Mars.setTextColor(Color.RED);
Earth.startAnimation(FadeIn);
Earth.setEnabled(false);
Earth.setTextColor(Color.RED);
}
});
Doom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), Checkpoint.class);
startActivity(i);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
Pluto.startAnimation(FadeIn);
Pluto.setEnabled(false);
Pluto.setTextColor(Color.RED);
Jupiter.startAnimation(FadeIn);
Jupiter.setEnabled(false);
Jupiter.setTextColor(Color.GREEN);
Mars.startAnimation(FadeIn);
Mars.setEnabled(false);
Mars.setTextColor(Color.RED);
Earth.startAnimation(FadeIn);
Earth.setEnabled(false);
Earth.setTextColor(Color.RED);
}
});
}
}