77 lines
2.3 KiB
Plaintext
77 lines
2.3 KiB
Plaintext
Fichier ConjugaisonActivity.java
|
|
|
|
package com.example.organisation;
|
|
|
|
import android.os.Bundle;
|
|
import android.widget.RadioButton;
|
|
import android.widget.RadioGroup;
|
|
import android.widget.TextView;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
public class ConjugaisonActivity extends AppCompatActivity {
|
|
private TextView phraseText;
|
|
private RadioGroup timeSelection;
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.activity_conjugaison);
|
|
|
|
phraseText = findViewById(R.id.phraseText);
|
|
timeSelection = findViewById(R.id.timeSelection);
|
|
|
|
timeSelection.setOnCheckedChangeListener((group, checkedId) -> {
|
|
String newText = "Je " + getConjugation(checkedId);
|
|
phraseText.setText(newText);
|
|
});
|
|
}
|
|
|
|
private String getConjugation(int id) {
|
|
if (id == R.id.passe) return "marchais";
|
|
if (id == R.id.present) return "marche";
|
|
if (id == R.id.futur) return "marcherai";
|
|
return "";
|
|
}
|
|
}
|
|
|
|
Fichier activity_conjugaison.xml
|
|
|
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="match_parent"
|
|
android:orientation="vertical"
|
|
android:padding="20dp">
|
|
|
|
<TextView
|
|
android:id="@+id/phraseText"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
android:text="Je marche"
|
|
android:textSize="18sp"/>
|
|
|
|
<RadioGroup
|
|
android:id="@+id/timeSelection"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
android:orientation="horizontal">
|
|
|
|
<RadioButton
|
|
android:id="@+id/passe"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
android:text="Passé"/>
|
|
|
|
<RadioButton
|
|
android:id="@+id/present"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
android:text="Présent"
|
|
android:checked="true"/>
|
|
|
|
<RadioButton
|
|
android:id="@+id/futur"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
android:text="Futur"/>
|
|
</RadioGroup>
|
|
</LinearLayout> |