47 lines
1.4 KiB
Plaintext
47 lines
1.4 KiB
Plaintext
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> |