Add DEV4.5/exo3_controle
This commit is contained in:
47
DEV4.5/exo3_controle
Normal file
47
DEV4.5/exo3_controle
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.example.partition;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class ResponseActivity extends AppCompatActivity {
|
||||
private TextView questionText;
|
||||
private Button answerButton;
|
||||
private String correctAnswer = "Bonne réponse!";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_response);
|
||||
|
||||
questionText = findViewById(R.id.questionText);
|
||||
answerButton = findViewById(R.id.answerButton);
|
||||
|
||||
answerButton.setOnClickListener(v -> questionText.setText(correctAnswer));
|
||||
}
|
||||
}
|
||||
|
||||
Fichier activity_response.xml
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="30dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/questionText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Quelle est la capitale de la France ?"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/answerButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Paris"
|
||||
android:layout_below="@id/questionText"
|
||||
android:layout_marginTop="20dp"/>
|
||||
</RelativeLayout>
|
||||
Reference in New Issue
Block a user