Académique Documents
Professionnel Documents
Culture Documents
6. Nous voulons passer de l’Activité « Act1 » à l’Activité « Act2 » quand on clique sur le
bouton « valider ». La méthode suivante est utilisée :
Valider.SetOnClick. . . . ..( new OnClick . . . .. ()){
@Override
public void onClick(. . . . .) {
Intent i = new Intent(act1, act2);
startActivity();
}
});
}
a. Compléter le code source du SetOnClick(). (2pt)
b. Citer les événements communs entre les vues dans une application Android. (2pts)
c. Chaque activité utilisée par une application doit être enregistrée dans le fichier «
AndroidManifest.xml» (a)-Vrai (b)-Faux (1pt)
d. Le fichier exécutable d’une application Android crée dans le dossier bin est
d’extension : (a)-.android, (b)- .exe, (c)-apke, (d)-jar, (e) .apk (f) .akp (1pt)
-------------------------------------------------------------------------------------------------
---
Partie TP/TD (14 pts)
7. Soit la méthode onCreate définie comme suit :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.id.activity_act2);
Button ajouter=(Button) findViewById(R.id.button1);
TextView tv = (TextView) findViewById(R.layout.textView1);
tv.append(nom+ " "+ mat);
ajouter.setOnLongClickListener(new ………. {
…………………
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Examen 2020, CoronaVirus",
5000).show();
return false;
} }); }
a). Corriger la méthode onCreate() 2pts
b). Quelle est l’avantage de la méthode append() 1pts
c). Corriger et compléter le contenu de cette méthode (SetOnLongClickListner). 2pts
d). Modifier cette méthode pour l’appeler par xml. 2pts
8. Soit le code source suivant :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
……………………..
………………………….
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nom" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:ems="10" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Prénom" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_weight="1"
android:ems="10" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Groupe" />
<EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_weight="1"
android:ems="10" />
</LinearLayout>
<LinearLayout
android:layout_width="301dp"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_weight="0.08"
android:gravity="center" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.85"
android:text="Calculer" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sauvegarder" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fermer" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Donner (tracer) l'interface IHM défini par cette portion du code (7pts)
Bon courage