I have different text view in the main activity and each one when clicked leads to another activity. All of them but the first one are disabled. The process should be, when being done with the first activity click the done button and it enables the next text view and also, I want keep the first text view enabled just incase the user wants to go back and fix his info. What I am trying to do is every time the user hits the done button it brings you back to the main activity and put an image or icon of a checked mark right next to the text view = activity that the user was done with.
Main Activity So basically in this main i receive an receive an intent from my other activities and i get a userNumber that is going to decide in witch If is going to go in.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//text view's in the main activity
personal = (TextView) findViewById(R.id.personal);
preference = (TextView) findViewById(R.id.preference);
music = (TextView) findViewById(R.id.music);
sports = (TextView) findViewById(R.id.sports);
//Each image view in the main activity
Icheck4 = (ImageView) findViewById(R.id.ICheck4);
Icheck3 = (ImageView) findViewById(R.id.ICheck3);
Icheck2 = (ImageView) findViewById(R.id.ICheck2);
Icheck1 = (ImageView) findViewById(R.id.ICheck1);
Intent in = getIntent();
preference.setEnabled(false);
music.setEnabled(false);
sports.setEnabled(false);
Icheck1.setVisibility(View.INVISIBLE);
Icheck2.setVisibility(View.INVISIBLE);
Icheck3.setVisibility(View.INVISIBLE);
Icheck4.setVisibility(View.INVISIBLE);
int myValue = in.getIntExtra("parametername1", 0);
if (myValue == 1) {
Icheck1.setVisibility(View.VISIBLE);
preference.setEnabled(true);
}
if (myValue2 == 2) {
Icheck2.setVisibility(View.VISIBLE);
preference.setEnabled(true);
music.setEnabled(true);
}
if (myValue == 3) {
Icheck3.setVisibility(View.VISIBLE);
preference.setEnabled(true);
music.setEnabled(true);
sports.setEnabled(true);
}
if (myValue == 4) {
Icheck4.setVisibility(View.VISIBLE);
preference.setEnabled(true);
music.setEnabled(true);
sports.setEnabled(true);
}
}
First Activity in this activity i created a callClick method so that every time the button clicks it sends a userNumber and it also gets me back to the Main Activity. and in the 2, 3 and 4 activity i have the same thing except, the userNumber changes because the user number is what is going to decide in witch IF is gonna go in in the Main Activity
public void callClick(View v){
int userNumber = 1;
Intent in = new Intent(MainActivity2Activity.this, MainActivity.class);
in.putExtra("parametername1", userNumber);
startActivity(in);
}
The problem than im having is that every time the user goes back to one of the earlier text views to edit his info the text views below that one get disabled again and also the checkmarks don't stay visible. How can i Fix this ??? Please. Is there a way that i could just launch and image instead of just having it invisible ???
You should use activity result to deal with it:
in MainActivity:
in MainActivity2Activity, don't use intent/startActivity, use this code to go back: