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 :

probleme de main.xml


Sujet :

Android

  1. #1
    Candidat au Club
    Inscrit en
    Août 2010
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Août 2010
    Messages : 2
    Par défaut probleme de main.xml
    bonjour
    je suis débutant en androïd
    j'ai un bug dans ficher main.xml
    et j'ai pas bien compris le problem

    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
     
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content">
     
    <TextView
    	        android:id="@+id/questions"
    	        android:layout_width="wrap_content"
      android:layout_height="wrap_content"
    	        android:text="@string/questions"
     
    	        android:textStyle="bold"
    	        />
     
    	    <RelativeLayout
    	    android:id="@+id/InnerRelativeLayoutQuestion"
    	    android:layout_width="wrap_content"
    	    android:layout_height="wrap_content"
    	    android:layout_centerInParent="true" >
     
    	        <RadioGroup android:layout_width="fill_parent"
    	        android:layout_height="wrap_content"
    	        android:orientation="vertical"
    	        android:id="@+id/radiogroup1">
     
    	            <RadioButton android:text="@string/data_suf_a"
    	                android:id="@+id/Rep1"
    	                android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:textSize="@dimen/txtdatasuf">
    	            </RadioButton>
    	            <RadioButton android:text="@string/data_suf_b"
    	                android:id="@+id/Rep2"
    	                android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:textSize="@dimen/txtdatasuf">
    	            </RadioButton>
                <RadioButton android:text="@string/data_suf_d" android:id="@+id/Rep4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="@dimen/txtdatasuf">
    	            </RadioButton><RadioButton android:text="@string/data_suf_c"
    	                android:id="@+id/Rep3"
    	                android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:textSize="@dimen/txtdatasuf">
    	            </RadioButton>
     
    	            <RadioButton android:text="@string/data_suf_e"
    	                android:id="@+id/Rep5"
    	                android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:textSize="@dimen/txtdatasuf">
    	            </RadioButton>
    	         </RadioGroup>
    	    </RelativeLayout>
     
    	    <RelativeLayout
    	        android:id="@+id/InnerRelativeLayout"
    	        android:layout_width="wrap_content"
    	        android:layout_height="wrap_content"
    	        android:layout_alignParentBottom="true" >
     
    	        <Button android:text="Next"
    	            android:id="@+id/Next"
    	            android:layout_alignParentRight="true"
    	            android:layout_width="wrap_content"
    	            android:layout_height="wrap_content">
    	        </Button>
     
    	    </RelativeLayout>
     
    	</RelativeLayout>

    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
     
     
    package demo.demo;
     
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.TextView;
     
    public class demo extends Activity {
        private static int count;
        public String[] questions = { "Is x an integer ?\n(1) x/2 is an integer \n(2) 2x is an integer",
                "What is the value of x ? \n(1)2x + 1=0 \n(2) (x+1)²=x²",
                "What is the value of 1/k + 1/r ? \n(1) k+r = 20 \n(2) kr = 64" };
     
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
     
     
     
           TextView quest = null ;
           Button btn = null ;
     
            if (count<3){
                quest.setText(count + "  " + questions[count]);
            }
            else{
                quest.setText(count + " questions " );
            }
     
            btn.setOnClickListener(new View.OnClickListener() {
     
                public void onClick(View view) {
                    newActivity();
     
                }
     
            });
     
        }
     
        public void newActivity (){
            Intent i = new Intent();
            i.setClass(this, demo.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(i);
            count++;
        }
    }
    merci beaucoup

  2. #2
    Rédacteur
    Avatar de MrDuChnok
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2002
    Messages
    2 112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2002
    Messages : 2 112
    Par défaut
    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
    TextView quest = null ;
           Button btn = null ;
     
            if (count<3){
                quest.setText(count + "  " + questions[count]);
            }
            else{
                quest.setText(count + " questions " );
            }
     
            btn.setOnClickListener(new View.OnClickListener() {
     
                public void onClick(View view) {
                    newActivity();
     
                }
     
            });
    quest et btn sont null, ils ne sont initialisés nulle part.
    J'imagine que ses éléments doivent être présent dans ton code XML ?
    Si oui, voilà un code pour récupérer ton instance et la manipuler dans ton code java :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    btn = (Button)findViewById(R.id.IdDuBouton);

  3. #3
    Candidat au Club
    Inscrit en
    Août 2010
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Août 2010
    Messages : 2
    Par défaut
    MrDuChnok
    j'ai fais commenca

    TextView quest = (TextView) findViewById(R.id.question);
    Button btn =(Button)findViewById(R.id.Next);

    il reste une erreur dans TextView

    et je sais pas pourquoi il y a des bug dans ficher xml

  4. #4
    Rédacteur
    Avatar de MrDuChnok
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2002
    Messages
    2 112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2002
    Messages : 2 112
    Par défaut
    Bonjour,

    Poste ici le code exact des erreurs ou des exceptions (vue LogCat sous Eclipse).
    Sans ça, difficile de t'aider.

Discussions similaires

  1. [Tomcat]probleme avec web.xml
    Par The_freeman dans le forum Tomcat et TomEE
    Réponses: 6
    Dernier message: 25/01/2006, 22h32
  2. [DOM] Probleme de parsing Xml en java
    Par bolivari dans le forum Format d'échange (XML, JSON...)
    Réponses: 4
    Dernier message: 25/01/2006, 19h42
  3. Probleme d'encode XML et java
    Par ujoodha dans le forum XML/XSL et SOAP
    Réponses: 2
    Dernier message: 25/10/2005, 09h24
  4. Probleme d'include XML/XSL en ASP
    Par baygz dans le forum XSL/XSLT/XPATH
    Réponses: 12
    Dernier message: 02/07/2004, 16h38

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