Bonjour
Je débute sur Android, j'ai lu les tutos et j'ai tenté de faire la premiere application Hello moi de TutoMobile. je rencontre plein de problèmes
1- premier message DDMS :
[2010-11-08 09:30:38 - DeviceMonitor]Sending jdwp tracking request failed!
2-dans dimensions.xml j'ai une erreur sur la ligne </resources>:
Element : resources
Content Model : (string?)*
3- sur string.xml j'ai une erreur sur la ligne <string name="bouton">Envoyer</string>:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 <?xml version="1.0" encoding="utf-8"?> <resources> <string name="dimMessage">30px</string> </resources>
Element : string
Content Model : ()*
4- dans main.xml j'ai une erreur sur la ligne <TextView android:id="@+id/TextViewHello" :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Hello moi</string> <string name="prenom">Jean-Claude</string> <string name="prenomHint">Jean-Claude</string> <string name="bouton">Envoyer</string> </resources>
error: Error: No resource found that matches the given name (at 'textColor' with value '@color/
couleurMessage').
5- dans Tutoriel1_Android.java c'est la cata il y a des erreurs à chaque ligne
Code : 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 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/TextViewPrenom" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/prenom" /> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" > <EditText android:id="@+id/EditTextPrenom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="bottom" android:hint="@string/prenomHint" /> <Button android:id="@+id/ButtonEnvoyer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/bouton" /> </LinearLayout> <TextView android:id="@+id/TextViewHello" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_gravity="center_horizontal" android:textSize="@dimen/dimMessage" android:textColor="@color/couleurMessage" /> </LinearLayout>
Pouvez-vous m'aider sur cette première appli afin que je comprenne le fonctionnement
Code : 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.tutomobile.android.tuto1; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; public class Tutoriel1_Android extends Activity { private EditText editText; private Button button; private String prenom; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //récupération de l'EditText grâce à son ID editText = (EditText) findViewById(R.id.EditTextPrenom); //récupération du bouton grâce à son ID button = (Button) findViewById(R.id.ButtonEnvoyer); //on applique un écouteur d'évenement au clique sur le bouton button.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { //on réupère le texte écrit dans l'EditText prenom = editText.getText().toString(); //on affiche "Hello votrePrenom ! " dans une petit pop-up qui s'affiche quelques seconde en bas d'écran Toast.makeText(Tutoriel1_Android.this, "Hello " + prenom + " !", Toast.LENGTH_LONG).show(); /*on affiche "Hello votrePrenom ! " dans un textView que l'on a créé tout à l'heure * et dont on avait pas précisé la valeur de son texte il s'agit du dernier TextView dans le fichier main.xml * De toute façon grâce à l'ID vous devrez facilement le trouver dans le fichier main.xml */ ((TextView)findViewById(R.id.TextViewHello)).setText("Hello " + prenom + " !"); } } ); } }
Merci pour vos réponses
JCM
Partager