Codes Sources Session Normale
Codes Sources Session Normale
Codes Sources Session Normale
MAINACTIVITY.JAVA
package com.example.ivan.sessionnormale;
import android.graphics.Color;
import android.support.constraint.ConstraintLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.QuickContactBadge;
import static android.graphics.Color.YELLOW;
public class MainActivity extends AppCompatActivity {
int k = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button button = (Button) findViewById(R.id.mon_button);
final ConstraintLayout constraintLayout = (ConstraintLayout)
findViewById(R.id.root);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (k==0){
k++;
constraintLayout.setBackgroundColor(Color.BLUE);
}
else {
if (k==1){
k++;
constraintLayout.setBackgroundColor(Color.RED);
}
else {
k--;
constraintLayout.setBackgroundColor(Color.BLUE);
}
}
}
});
}
}