From de69e1d700f01ec0239b5c0c9e0be1c98e5f5c16 Mon Sep 17 00:00:00 2001 From: sayebabu Date: Thu, 8 Feb 2024 15:05:11 +0100 Subject: [PATCH] android TP3 ex1 --- .../Fleche/.idea/deploymentTargetDropDown.xml | 10 +++++++++ DEV4.5/Fleche/.idea/gradle.xml | 5 +++-- DEV4.5/Fleche/.idea/migrations.xml | 10 +++++++++ DEV4.5/Fleche/.idea/misc.xml | 2 +- DEV4.5/Fleche/.idea/vcs.xml | 6 ++++++ .../com/example/fleche/FlecheListener.java | 21 ++++++++++++++++--- .../java/com/example/fleche/MainActivity.java | 2 +- .../app/src/main/res/layout/activity_main.xml | 6 ++---- 8 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 DEV4.5/Fleche/.idea/deploymentTargetDropDown.xml create mode 100644 DEV4.5/Fleche/.idea/migrations.xml create mode 100644 DEV4.5/Fleche/.idea/vcs.xml diff --git a/DEV4.5/Fleche/.idea/deploymentTargetDropDown.xml b/DEV4.5/Fleche/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..0c0c338 --- /dev/null +++ b/DEV4.5/Fleche/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/DEV4.5/Fleche/.idea/gradle.xml b/DEV4.5/Fleche/.idea/gradle.xml index a9f4e52..0897082 100644 --- a/DEV4.5/Fleche/.idea/gradle.xml +++ b/DEV4.5/Fleche/.idea/gradle.xml @@ -1,17 +1,18 @@ + diff --git a/DEV4.5/Fleche/.idea/migrations.xml b/DEV4.5/Fleche/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/DEV4.5/Fleche/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/DEV4.5/Fleche/.idea/misc.xml b/DEV4.5/Fleche/.idea/misc.xml index 9f71c83..0ad17cb 100644 --- a/DEV4.5/Fleche/.idea/misc.xml +++ b/DEV4.5/Fleche/.idea/misc.xml @@ -1,7 +1,7 @@ - + diff --git a/DEV4.5/Fleche/.idea/vcs.xml b/DEV4.5/Fleche/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/DEV4.5/Fleche/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DEV4.5/Fleche/app/src/main/java/com/example/fleche/FlecheListener.java b/DEV4.5/Fleche/app/src/main/java/com/example/fleche/FlecheListener.java index 9464604..5827dc0 100644 --- a/DEV4.5/Fleche/app/src/main/java/com/example/fleche/FlecheListener.java +++ b/DEV4.5/Fleche/app/src/main/java/com/example/fleche/FlecheListener.java @@ -1,17 +1,32 @@ package com.example.fleche; import android.content.DialogInterface; +import android.util.Log; import android.view.View; +import android.widget.Button; import android.widget.ImageView; public class FlecheListener implements View.OnClickListener { - FlecheListener(ImageView img) { - + private ImageView imgFleche; + private Button ButtonG; + private Button ButtonD; + FlecheListener(ImageView img, Button bg, Button bd) { + super(); + this.imgFleche = img; + this.ButtonG = bg; + this.ButtonD = bd; } @Override public void onClick(View view) { - //if (view.getId()==) + if(view.getId()==ButtonD.getId()) { + this.imgFleche.setImageResource(R.drawable.fleche_droite); + Log.v("test","droite"); + } + if (view.getId()==ButtonG.getId()) { + this.imgFleche.setImageResource(R.drawable.fleche_gauche); + Log.v("test","gauche"); + } } } diff --git a/DEV4.5/Fleche/app/src/main/java/com/example/fleche/MainActivity.java b/DEV4.5/Fleche/app/src/main/java/com/example/fleche/MainActivity.java index 5badd27..7a14ae7 100644 --- a/DEV4.5/Fleche/app/src/main/java/com/example/fleche/MainActivity.java +++ b/DEV4.5/Fleche/app/src/main/java/com/example/fleche/MainActivity.java @@ -16,6 +16,6 @@ public class MainActivity extends AppCompatActivity { ImageView FlecheImg = (ImageView) findViewById(R.id.flecheImg); Button btnFlecheG = (Button) findViewById(R.id.flecheGauche); Button btnFlecheD = (Button) findViewById(R.id.flecheDroite); - btnFlecheG.setOnClickListener(); + btnFlecheG.setOnClickListener(new FlecheListener(FlecheImg,btnFlecheG,btnFlecheD)); } } \ No newline at end of file diff --git a/DEV4.5/Fleche/app/src/main/res/layout/activity_main.xml b/DEV4.5/Fleche/app/src/main/res/layout/activity_main.xml index c651e72..68351d5 100644 --- a/DEV4.5/Fleche/app/src/main/res/layout/activity_main.xml +++ b/DEV4.5/Fleche/app/src/main/res/layout/activity_main.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="16dp" - android:paddingRight="16dp" > + android:paddingRight="16dp"> - + \ No newline at end of file