1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Vibrator;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
/**
* Created by on 02/07/2017.
*/
public class pateActivity extends Activity {
TextView textpate;
Button btp;
Button Test;
Button reset;
Button back;
CheckBox checkBox6;
CheckBox checkBox8;
Switch switch6;
Switch switch8;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pate);
btp = (Button) findViewById(R.id.bpate);
textpate = (TextView) findViewById(R.id.textpate);
Test = (Button) findViewById(R.id.Test);
reset = (Button) findViewById(R.id.boutonReset);
back = (Button) findViewById(R.id.back);
checkBox6 = (CheckBox)findViewById(R.id.patecheckbox1);
checkBox8 =(CheckBox)findViewById(R.id.patecheckbox2);
switch6 =(Switch)findViewById(R.id.switch6);
switch8 =(Switch)findViewById(R.id.switch8);
btp.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
CountDownTimer zountDownTimer = new CountDownTimer(1 * 1000, 1000) {
// je voudrai si possible que la valeur 1 soit modifier en fonction de switch6 ou switch8 car je voudrai que switch6 = 360 et switch8 = 480
//merci d'avance et dsl si la reponse est évidente mais j'ai beau passé 4h à chercher je n'y arrive plus.
public Activity context;
@Override
public void onTick(long millisUntilFinished) {
textpate.setText("" + millisUntilFinished / 1000 + "Secondes");
reset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cancel();
textpate.setText("00");
}
});
}
@Override
public void onFinish() {
textpate.setText("Grouille tes pates sont finies !!!");
final Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vib.vibrate(10000);
reset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vib.cancel();
textpate.setText("00");
}
});
}
}.start();
}
}); |
Partager