IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Erreur Resources$ NotFoundException


Sujet :

Android

  1. #1
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2013
    Messages
    103
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2013
    Messages : 103
    Points : 59
    Points
    59
    Par défaut Erreur Resources$ NotFoundException
    Bonjour,

    Quand je souhaite démarrer une autre activité, l'émulateur plante et l'erreur ci-dessous apparait dans le logcat
    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
    06-11 16:36:36.729: E/AndroidRuntime(607): FATAL EXCEPTION: main
    06-11 16:36:36.729: E/AndroidRuntime(607): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.cartedefidelite/com.example.cartedefidelite.DetailClientActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x9
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.app.ActivityThread.access$600(ActivityThread.java:122)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.os.Handler.dispatchMessage(Handler.java:99)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.os.Looper.loop(Looper.java:137)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.app.ActivityThread.main(ActivityThread.java:4340)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at java.lang.reflect.Method.invokeNative(Native Method)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at java.lang.reflect.Method.invoke(Method.java:511)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at dalvik.system.NativeStart.main(Native Method)
    06-11 16:36:36.729: E/AndroidRuntime(607): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x9
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.content.res.Resources.getText(Resources.java:247)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.widget.TextView.setText(TextView.java:3428)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at com.example.cartedefidelite.DetailClientActivity.onCreate(DetailClientActivity.java:70)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.app.Activity.performCreate(Activity.java:4465)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
    06-11 16:36:36.729: E/AndroidRuntime(607): 	... 11 more
    Voici les 2 activités entre lesquelles ça plante :
    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    public class DetailClientActivity extends FideliteActivity{
    	  clientBDD cliBDD = new clientBDD(this);
    	  String nomduclient;
     
    	  protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		Bundle objetbundle = this.getIntent().getExtras();
    	    nomduclient = objetbundle.getString("nomclient");
    	    cliBDD.open();
    	    cli = cliBDD.getClientwithNom(nomduclient);
    	    LinearLayout LL = new LinearLayout(this);
    	    TextView tv = new TextView(this);
            TextView tv1 = new TextView(this);
            TextView tv2 = new TextView(this);
            TextView tv3 = new TextView(this);
            TextView tv4 = new TextView(this);
            TextView tv5 = new TextView(this);
            TextView tv6 = new TextView(this);
            TextView tv7 = new TextView(this);
            TextView tv8 = new TextView(this);
     
            LayoutParams LLParam = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            LayoutParams LPtv = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            LayoutParams LPtv1 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
            LayoutParams LPtv2 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
            LayoutParams LPtv3 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
            LayoutParams LPtv4 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
            LayoutParams LPtv5 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
            LayoutParams LPtv6 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
            LayoutParams LPtv7 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
            LayoutParams LPtv8 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
     
            LL.setOrientation(LinearLayout.VERTICAL);
            LL.setLayoutParams(LLParam);
            tv.setLayoutParams(LPtv1);
            tv1.setLayoutParams(LPtv);
            tv2.setLayoutParams(LPtv2);
            tv3.setLayoutParams(LPtv3);
            tv4.setLayoutParams(LPtv4);
            tv5.setLayoutParams(LPtv5);
            tv6.setLayoutParams(LPtv6);
            tv7.setLayoutParams(LPtv7);
            tv8.setLayoutParams(LPtv8);
     
     
            LL.addView(tv); 
            LL.addView(tv1);
            LL.addView(tv2);
            LL.addView(tv3);
            LL.addView(tv4);
            LL.addView(tv5);
            LL.addView(tv6);
            LL.addView(tv7);
            LL.addView(tv8);
     
            tv.setText(cli.getNom());
            tv1.setText(cli.getPrenom());
            tv2.setText(cli.getAdresse());
            tv3.setText(cli.getCp());
            tv4.setText(cli.getVille());
            tv5.setText(cli.getMail());
            tv6.setText(cli.getTel());
            tv7.setText(cli.getNbpizzaencours());
            tv8.setText(cli.getNbpizzatotal());
     
            setContentView(LL);
     
         }
    }
    et
    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
    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
    81
    82
    83
    84
    public class FideliteActivity extends AffichageClientActivity /*implements View.OnClickListener*/ {
    	clientBDD clibdd = new clientBDD(this);
    	EditText nombre;
    	Button detail;
    	Button ok;
    	String nomduclient;
     
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.fidelite);
    		//récupération de la valeur de l'edittext
    		Bundle objetbundle = this.getIntent().getExtras();
    	    nomduclient = objetbundle.getString("nomclient");
    		detail = (Button) findViewById(R.id.Detail);
    		ok = (Button) findViewById(R.id.valider);
    		nombre = (EditText) findViewById(R.id.nb);
    		ok.setOnClickListener(validerListener);
    		detail.setOnClickListener(detailclientListener);
    	}
     
    	private OnClickListener validerListener = new OnClickListener(){
    		public void onClick(View v){
    			if(v==ok){
    			//récupération de la valeur dans l'EditText
    			String nb = nombre.getText().toString();
    			int nbpizz = Integer.parseInt(nb);
    			//connexion à la BDD et récupération du nombre de pizza existant
    			cliBDD.open();
    			cli = cliBDD.getNbpizzawithNom(nomduclient);
    			int nbexist = cli.getNbpizzaencours();
     
    			//calcul plus affichage des avantages fidelité
    			nbexist = nbexist + nbpizz;
    			if(nbexist >=30)
    			{
    				Toast.makeText(
    						FideliteActivity.this,
    						"3 pizzas gratuites!",
    						Toast.LENGTH_LONG).show();
    				nbexist = nbexist-30;
    			}
    			else if(nbexist >=20){
    				Toast.makeText(
    						FideliteActivity.this,
    						"2 pizzas gratuites!",
    						Toast.LENGTH_LONG).show();
    				nbexist = nbexist-20;
     
    			}else if(nbexist >=10){
    				Toast.makeText(
    						FideliteActivity.this,
    						"1 pizza gratuite!",
    						Toast.LENGTH_LONG).show();
    				nbexist = nbexist-10;
    			}
    			else{
    				Toast.makeText(
    						FideliteActivity.this,
    						"Pas de pizza gratuite pour cette fois!",
    						Toast.LENGTH_LONG).show();
    			}
     
    			//mis à jour de la BDD
    			//cliBBD.updateClient(int id, client cli);
     
     
    			//fermeture de la BDD
    			cliBDD.close();
     
    			}
    		}
    	};
     
    	private OnClickListener detailclientListener = new OnClickListener(){
    		public void onClick(View v){
    		Intent versDetail = new Intent(getApplicationContext(),
    		    DetailClientActivity.class);
    			versDetail.putExtra("nomclient",nomduclient);
    			startActivity(versDetail);
     
    		}
    	};
     
    }
    Comment remédier à ce problème?
    Merci d'avance

  2. #2
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    757
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 757
    Points : 968
    Points
    968
    Par défaut
    Le problème vient certainement d'un setText().
    Cette méthode a besoin d'une chaine de caractère en paramètre.
    Or je pense qu'il y a certaines valeurs qui doivent être des int.
    Pour ce faire, tu peux simplement utiliser ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    textView.setText(String.valueOf(taVariable));

  3. #3
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2013
    Messages
    103
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2013
    Messages : 103
    Points : 59
    Points
    59
    Par défaut
    En effet, c'était ça, merci bien!

Discussions similaires

  1. [MySQL] Erreur : Resource id #5 (problème affichage variable)
    Par bond70 dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 28/04/2010, 15h26
  2. [MySQL] Que veut dire ce message d'erreur Resource id #4
    Par pierrot10 dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 04/04/2010, 22h28
  3. [MySQL] dupliquer un login selon le prénom et le nom - erreur "Resource id #14" PQ ?
    Par bilou95 dans le forum PHP & Base de données
    Réponses: 6
    Dernier message: 05/07/2007, 17h07
  4. [ImageMagick] imagecopyresized erreur resource
    Par webrider dans le forum Bibliothèques et frameworks
    Réponses: 8
    Dernier message: 11/09/2006, 13h33
  5. Erreur : "resource discarded"
    Par AraBorLeg dans le forum Langage
    Réponses: 2
    Dernier message: 27/12/2005, 15h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo