Salut à tous. Après avoir lu tous les tutos et une recherche sur cette plateforme, je n'arrive pas à résoudre mon problème de passage d'une activité à une autre. Voilà mes codes :
Code Main.java :
Code JAVA : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 package com.sigespe.ovono.sigespe; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class Main extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //Bouton espace personnel Button espacepersonnel = (Button) findViewById(R.id.espacepersonnel); espacepersonnel.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent myIntent = new Intent(getBaseContext(), Espace_Personnel.class); startActivityForResult(myIntent, 0); } }); //Bouton espace admoinistrateur Button administration = (Button) findViewById(R.id.administration); administration.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent myIntent = new Intent(getBaseContext(), Menu_Admin.class); startActivityForResult(myIntent, 0); } }); //Bouton espace fermer Button fermer = (Button) findViewById(R.id.fermer); Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startMain); } }
Code main.xml
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".Main"> <TextView android:id="@+id/sigesper" android:layout_width="368dp" android:layout_height="wrap_content" android:text="Système Intelligent de Gestion des Présences Effectives (SIGESPER)" android:textColor="Black" android:textSize="24sp" tools:ignore="MissingConstraints" tools:layout_editor_absoluteX="8dp" /> <TextView android:id="@+id/accueil" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="24dp" android:text="Accueil" android:textColor="Black" android:textSize="30sp" app:layout_constraintTop_toBottomOf="@+id/sigesper" tools:ignore="MissingConstraints" tools:layout_editor_absoluteX="143dp" /> <Button android:id="@+id/espacepersonnel" android:layout_width="184dp" android:layout_height="48dp" android:text="ESPACE PERSONNEL" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" tools:ignore="MissingConstraints" tools:layout_editor_absoluteY="161dp" /> <Button android:id="@+id/administration" android:layout_width="182dp" android:layout_height="wrap_content" android:text="ADMINISTRATION" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" tools:ignore="MissingConstraints" tools:layout_editor_absoluteY="247dp" /> <Button android:id="@+id/fermer" android:layout_width="179dp" android:layout_height="wrap_content" android:text="Fermer" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" tools:layout_editor_absoluteY="331dp" tools:ignore="MissingConstraints" /> <TextView android:id="@+id/copyright" android:layout_width="273dp" android:layout_height="24dp" android:text="© 2018 - SIGESPER - Tous droits réservés." android:textColor="Black" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.414" app:layout_constraintStart_toStartOf="parent" tools:ignore="MissingConstraints" tools:layout_editor_absoluteY="402dp" />6 </android.support.constraint.ConstraintLayout>
Code manifest.xml
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.sigespe.ovono.sigespe"> <!-- To auto-complete the email text field in the login form with the user's emails --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <uses-feature android:name="android.hardware.fingerprint" android:required="true" tools:ignore="WrongManifestParent" /> <uses-permission android:name="android.permission.USE_FINGERPRINT" tools:ignore="WrongManifestParent" /> <activity android:name=".main"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Enregistrement_du_personnel"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Ajouter_service"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Activer_ma_presence_effective"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Espace_Service"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Espace_Personnel"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Espace_Personnel_Admin" /> <activity android:name=".Menu_Admin" /> <activity android:name=".Connexion_Personnel" /> <activity android:name=".Connexion_Admin" /> <activity android:name=".Main"></activity> </application> </manifest>
En cliquant sur le bouton Espace Personnel ça doit me renvoyer le formulaire Espace personnel:
Espace_Personnel.java
Code :
Code JAVA : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 package com.sigespe.ovono.sigespe; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.app.Activity; public class Espace_Personnel extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_espace__personnel); } }
Activite_espace_personnel.xml
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".Espace_Personnel"> <TextView android:id="@+id/copyright4" android:layout_width="273dp" android:layout_height="24dp" android:text="© 2018 - SIGESPER - Tous droits réservés." android:textColor="Black" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" tools:ignore="MissingConstraints" tools:layout_editor_absoluteY="402dp" /> <TextView android:id="@+id/espacepersonnel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ESPACE PERSONNEL" android:textSize="24sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" /> <Button android:id="@+id/s_enregistrer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="S'ENREGISTRER" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" tools:layout_editor_absoluteY="70dp" tools:ignore="MissingConstraints" /> <Button android:id="@+id/activersapresence" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ACTIVER MA PRESENCE" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" tools:layout_editor_absoluteY="160dp" tools:ignore="MissingConstraints" /> <Button android:id="@+id/quitter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="QUITTER" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" tools:layout_editor_absoluteY="251dp" tools:ignore="MissingConstraints" /> </android.support.constraint.ConstraintLayout>
Voilà la capture d'écran du code Main.java
Les R de R.layout.main, R.id.espacepersonnel, R.id.administration et R.id.fermer sont en rouge et je ne sais pas le pourquoi.
Merci d'avance !
Cordialement !!!
Partager