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

Composants graphiques Android Discussion :

pb affichage resultat d'un curseur dans listview


Sujet :

Composants graphiques Android

  1. #1
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2015
    Messages : 33
    Points : 15
    Points
    15
    Par défaut pb affichage resultat d'un curseur dans listview
    j ai trois activités la premiere c un formulaire d'authentification login et mot de passe (j injecte le login dans un itent que je recupérerai dans la l'activité 3( soldecompte)), la 2eme contient un edit text ou je recupere un numcpte que j injecte dans un intent que je recupere dans l'activité 3 (soldecompte)), la 3eme ativité contient une list view ou je voudrai afficher le solde d'un compte en utilisant le login et numcpte que j ai récupéré dans les 2 activités precedentes.

    mn pb c'est qil ne maffiche absolument rien dans la 3eme ativité.et je nai rien ds le logcat

    dnc je vous donne les code des activités + les xml et le ode conernat la bdd JE FAIS APPEL A "ConsultationSolde"

    SVP c'est urgent , POUVEZ VOUS M'AIDER?

    MERCI

    activité1


    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
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    package com.example.app;
    import com.example.app.R;
     
    import android.support.v7.app.ActionBarActivity;
    import android.text.TextWatcher;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.text.Editable;
     
    import java.lang.Object;
     
     
     
    import java.text.SimpleDateFormat;
    import java.util.Date;
     
     
     
     
     
     
     
     
    //import android.app.Activity;
    //import android.os.Bundle;
    //import android.view.KeyEvent;
    //import android.view.MotionEvent;
    import android.view.View;
    import android.view.View.OnClickListener;
    //import android.view.View.OnKeyListener;
    import android.widget.Button;
    import android.widget.CheckBox;
    import android.widget.DatePicker;
    import android.widget.EditText;
    import android.widget.RadioGroup;
    import android.widget.TextView;
    import android.widget.Toast;
    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.content.Intent;
     
    public class Ex_conn extends ActionBarActivity {
     
     
     
        static String key="a";
     
     
              EditText login= null;
              EditText mdp = null;
     
     
     
              Button valider = null;
              Button retour = null;
     
     
     
     
                ClientsbBDD clientbBdd = new ClientsbBDD(this);
     
     
              @Override
                protected void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.activity_ex_conn);
     
     
     
                // On récupère toutes les vues dont on a besoin
     
              valider = (Button)findViewById(R.id.valider);
     
             retour = (Button)findViewById(R.id.retour);
     
     
                login = (EditText)findViewById(R.id.login);
                mdp = (EditText)findViewById(R.id.mdp);
     
     
               // text_date_nais = (TextView)findViewById(R.id.text_date_nais);
     
     
     
                valider.setOnClickListener(validerListener);
     
     
               login.addTextChangedListener(textWatcher);
                mdp.addTextChangedListener(textWatcher);
     
     
     
     
     
              }
     
                private OnClickListener validerListener = new OnClickListener() {
                    @Override
                    public void onClick(View v) {
     
     
     
                        String chaine5 = login.getText().toString();
                        String chaine6 = mdp.getText().toString();
     
     
     
     
     
                            if(
                                    (chaine5.equals(""))|| (chaine6.equals(""))){
                                        message();
     
                                     }
     
     
     
     
                            try{ 
                                   if(chaine5.length() > 0 && chaine6.length() >0)
                                    {
                                        ClientsbBDD dbUser = new ClientsbBDD(Ex_conn.this);
                                        dbUser.open();
     
                                        if(dbUser.Login(chaine5, chaine6))
                                        { Intent secondeActivite = new Intent(Ex_conn.this,Menuu.class);
                                        secondeActivite.putExtra(key,chaine5);
     
                                        startActivity(secondeActivite);
                                        }else{
                                            Toast.makeText(Ex_conn.this,"Invalid Username/Password", Toast.LENGTH_LONG).show();
                                        }
                                        dbUser.close();
                                    }
     
                                }catch(Exception e)
                                {
                                    Toast.makeText(Ex_conn.this,e.getMessage(), Toast.LENGTH_LONG).show();
                                }
     
     
     
     
     
     
                    }
                 };
     
                 /* public void DemoAlertDialog(){
                         
                        AlertDialog.Builder ad = new AlertDialog.Builder(this);
                        ad.setIcon(R.drawable.ic_launcher);
                        ad.setTitle("Erreur");
                        //ad.setView(LayoutInflater.from(this).inflate(R.layout.activity_dialog,null));
                        ad.setMessage("Format incorrect");
                         
                        ad.setNegativeButton("Bouton non",
                                new android.content.DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int arg1) {
                                        //OK
                                    }
                                });
                             
                             
                 
                             
                            ad.setOnCancelListener(new DialogInterface.OnCancelListener(){
                                public void onCancel(DialogInterface dialog) {
                                    // OK              
                                }}
                            );
                             
                            ad.show();
                             
                             
                             
                        }*/
     
     
                  private TextWatcher textWatcher = new TextWatcher() {
     
                        @Override
                        public void onTextChanged(CharSequence s, int start, int before, int count) {
                          //result.setText(defaut);
                        }
     
                        @Override
                        public void beforeTextChanged(CharSequence s, int start, int count,
                          int after) {
     
                        }
     
     
                        @Override
                        public void afterTextChanged(Editable s) {
                            // TODO Auto-generated method stub
     
                        }
                      };
     
     
                      public void message(){
                            Toast.makeText(this, "il faut remplir ts les champs", Toast.LENGTH_SHORT).show(); 
                          }
                          public void boite(){
                              Toast.makeText(this, " Le mot de passe est 1 est != de 2", Toast.LENGTH_SHORT).show(); 
                          }
     
                          public void boite1(){
                              Toast.makeText(this, "le nom utilisateur existe déjà", Toast.LENGTH_SHORT).show(); 
                          }
                public void controle1(){
                    clientbBdd = new ClientsbBDD(this);
                }
     
     
     
            }

    l'activité2

    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
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
     
     
    package com.example.app;
     
    import android.app.Activity;
    import android.content.Intent;
    import android.database.Cursor;
    import android.os.Bundle;
    import android.text.Editable;
    import android.text.TextWatcher;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.SimpleCursorAdapter;
    import android.widget.TextView;
    import android.widget.Toast;
    import android.widget.ListView;
     
    public class Consultation extends Activity {
     
     
     
        ClientsbBDD datasource=new ClientsbBDD(this);
     
        ListView lv1;
         //TextView solde;
     
          EditText numcpte= null;
        String chaine;
     
          Button valider;
          Button retour = null;
          static String key2="bb";
     
          ClientsbBDD clientbBdd = new ClientsbBDD(this);
     
     
     
          @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_consultation);
     
                //solde = (TextView) this.findViewById(R.id.solde);
     
                 valider = (Button)findViewById(R.id.valider);
     
         retour = (Button)findViewById(R.id.retour);
     
     
           numcpte = (EditText)findViewById(R.id.numcpte);
     
     
     
     
           valider.setOnClickListener(validerListener);
     
     
         numcpte.addTextChangedListener(textWatcher);
     
     
        // solde.addTextChangedListener(textWatcher);
     
     
     
         Compte compte1 = new  Compte("77",22,"ll","zz",55,55);
          Compte compte2 = new  Compte("66",22,"33","44",55,44);
          Compte compte3 = new  Compte("55",22,"33","44",55,66);
          Compte compte4 = new  Compte("44",22,"33","44",55,66);
          Compte compte5 = new  Compte("110",120,"130","140",160,170);
          clientbBdd.open();
           clientbBdd.insertCompte(compte1);
           clientbBdd.insertCompte(compte2);
           clientbBdd.insertCompte(compte3);
           clientbBdd.insertCompte(compte4);
           clientbBdd.insertCompte(compte5);
     
     
          /* Intent i = getIntent();
           Bundle extras= getIntent().getExtras();
            age = i.getStringExtra(Ex_conn.key);
           solde.setText(age); */
     
     
     
     
     
     
     
          }
     
     
     
     
     
           private OnClickListener validerListener = new OnClickListener() {
            @Override
            public void onClick(View v) {
     
     
     
               chaine = numcpte.getText().toString();
            // Compte compteFromBdd = clientbBdd.getSdeWithNCP(chaine);
     
     
     
     
                        if(
                                (chaine.equals(""))){
                                    message();
     
                                 }
     
     
     
     
                        try{ 
                               if(chaine.length() > 0)
                                {
                                    /*ClientsbBDD dbUser = new ClientsbBDD(Consultation.this);
                                    dbUser.open();
                                     
                                    if(dbUser.Auth_compte(chaine))
                                    {  Toast.makeText(Consultation.this, compteFromBdd.toString(), Toast.LENGTH_LONG).show();*/
     
     
                                   Intent secondeActivitee=new Intent(Consultation.this, SoldeCompte.class);
     
     
                                 secondeActivitee.putExtra(key2,chaine);
     
                                 startActivity(secondeActivitee);
     
                                    }else{
                                        Toast.makeText(Consultation.this,"Ce numero de compte n'existe pas", Toast.LENGTH_LONG).show();
                                    }
                                    //dbUser.close();
                                }
     
                            catch(Exception e)
                            {
                                Toast.makeText(Consultation.this,e.getMessage(), Toast.LENGTH_LONG).show();
                            }
     
     
     
     
            }
         };
     
     
     
     
          private TextWatcher textWatcher = new TextWatcher() {
     
                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                  //result.setText(defaut);
                }
     
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
     
                }
     
     
                @Override
                public void afterTextChanged(Editable s) {
                    // TODO Auto-generated method stub
     
                }
              };
     
     
              public void message(){
                    Toast.makeText(this, "il faut remplir tt les champs", Toast.LENGTH_SHORT).show(); 
                  }
     
     
     
     
       }
    l'activité3

    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
    package com.example.app;
     
     
     
    import android.content.Intent;
    import android.database.Cursor;
    import android.os.Bundle;
    import android.support.v7.app.ActionBarActivity;
    import android.widget.ListView;
    import android.widget.SimpleCursorAdapter;
    import android.widget.TextView;
     
    public class SoldeCompte extends ActionBarActivity {
        private ClientsbBDD datasource;
     
     
     
    //ClientsbBDD datasource=new ClientsbBDD(this);
     
        ListView lv1;
        // TextView solde;
     
     
     
        String key;
        String key2;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_solde_compte);
            //solde = (TextView)findViewById(R.id.solde);
     
              Intent i = getIntent();
     
              // Bundle extras= getIntent().getExtras();
     
                key = i.getStringExtra(Ex_conn.key);
     
                key2 = i.getStringExtra(Consultation.key2);
     
     
     
     
     
            // Puis on récupère l'âge donné dans l'autre activité, ou 0 si cet extra n'est pas dans l'intent
     
     
     
          // text.setText(age8 );
            // S'il ne s'agit pas de l'âge par défaut
           // if(age != 0)
              // Traiter l'âge
             // age = 2;
     
     
               datasource = new ClientsbBDD(this);
     
              datasource.open();
     
               datasource.close();
     
     
        }
     
         public void afffiche(){
             lv1=(ListView)findViewById(R.id.lv1);
                //récuperer les donnnée
                Cursor c = datasource.ConsultationSolde(key,key2);
                //s'occuper du cursseur par exemple pr libérer la memoire
                startManagingCursor(c);
                //et la les données récupérer qui seront afficher dns les champs de list_item
                SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
                R.layout.list_item,c,new String[]{"SDE"},
                new int[]{R.id.solde});
                lv1.setAdapter(adapter);
            }
     
     
     
     
     
     
    }

    son xml
    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
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.app.SoldeCompte" >
     
         <ListView
              android:id="@+id/lv1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
     
     
     
    </LinearLayout>

    listitem
    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
     
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
     
     
     
     
         <TextView
              android:id="@+id/solde"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
     
                     android:layout_marginTop="70dip"
                android:gravity="center"
                  android:textColor="#5A5E6B" />
    </LinearLayout>

    code bdd je fais appel a ConsultationSolde (tout en bas de e code)
    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
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    package com.example.app;
    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.SQLException;
    import android.database.sqlite.SQLiteDatabase;
    import android.widget.Spinner;
    import android.widget.DatePicker;
     
     
    public class ClientsbBDD {
            private static final int VERSION_BDD =3;
            private static final String NOM_BDD = "client_bankkkk";
     
            private static final String TABLE_CLIENTSB = "client";
            private static final String COL_ID = "ID";
            private static final int NUM_COL_ID = 0;
            private static final String COL_CLT = "CLT";
            private static final int NUM_COL_CLT = 1;
     
            private static final String COL_NOM = "Nom";
            private static final int NUM_COL_NOM = 2;
     
            private static final String COL_PRENOM = "PRENOM";
            private static final int NUM_COL_PRENOM = 3;
     
            private static final String COL_DATE_NAIS = "DATE_NAIS";
            private static final int NUM_COL_DATE_NAIS = 4;
     
            private static final String COL_EMAIL = "EMAIL";
            private static final int NUM_COL_EMAIL = 5;
     
            private static final String COL_LOGIN = "LOGIN";
            private static final int NUM_COL_LOGIN = 6;
     
            private static final String COL_MDP = "MDP";
            private static final int NUM_COL_MDP = 7;
     
     
     
     
            private static final String TABLE_CLIENTSB2 = "compte";
            private static final String COL_IDC = "IDC";
            private static final int NUM_COL_IDC = 0;
            private static final String COL_NCP = "NCP";
            private static final int NUM_COL_NCP = 1;
            private static final String COL_CLC = "CLC";
            private static final int NUM_COL_CLC = 2;
     
            private static final String COL_INTI = "INTI";
            private static final int NUM_COL_INTI = 3;
     
            private static final String COL_DOU = "DOU";
            private static final int NUM_COL_DOU = 4;
     
            private static final String COL_SDE = "SDE";
            private static final int NUM_COL_SDE = 5;
     
            private static final String COL_CLI = "CLI";
            private static final int NUM_COL_CLI = 6;
            private SQLiteDatabase bdd;
     
     
     
            private MaBaseSQLite maBaseSQLite;
     
            public ClientsbBDD(Context context){
                //On créer la BDD et sa table
                maBaseSQLite = new MaBaseSQLite(context, NOM_BDD, null, VERSION_BDD);
            }
     
            public void open(){
                //on ouvre la BDD en écriture
                bdd = maBaseSQLite.getWritableDatabase();
            }
     
            public void close(){
                //on ferme l'accès à la BDD
                bdd.close();
            }
     
            public SQLiteDatabase getBDD(){
                return bdd;
            }
     
            public long insertClientb(Clientb clientb){
                //Création d'un ContentValues (fonctionne comme une HashMap)
                ContentValues values = new ContentValues();
                //on lui ajoute une valeur associé à une clé (qui est le nom de la colonne dans laquelle on veut mettre la valeur)
                values.put(COL_CLT, clientb.getClt());
                values.put(COL_PRENOM, clientb.getPrenom());
                values.put(COL_NOM, clientb.getNom());
                values.put(COL_DATE_NAIS, clientb.getDate_nais());
                values.put(COL_EMAIL, clientb.getEmail());
                values.put(COL_LOGIN, clientb.getLogin());
                values.put(COL_MDP, clientb.getMdp());
                //on insère l'objet dans la BDD via le ContentValues
                return bdd.insert(TABLE_CLIENTSB, null, values);
            }
     
            public long insertCompte(Compte compte){
                //Création d'un ContentValues (fonctionne comme une HashMap)
                ContentValues values = new ContentValues();
                //on lui ajoute une valeur associé à une clé (qui est le nom de la colonne dans laquelle on veut mettre la valeur)
                values.put(COL_NCP, compte.getNcp());
                values.put(COL_CLC, compte.getClc());
                values.put(COL_INTI, compte.getInti());
                values.put(COL_DOU, compte.getDou());
                values.put(COL_SDE, compte.getSde());
                values.put(COL_CLI, compte.getCli());
     
                //on insère l'objet dans la BDD via le ContentValues
                return bdd.insert(TABLE_CLIENTSB2, null, values);
            }
     
            public int updateClientb(int id, Clientb clientb){
                //La mise à jour d'un livre dans la BDD fonctionne plus ou moins comme une insertion
                //il faut simple préciser quel client on doit mettre à jour grâce à l'ID
                ContentValues values = new ContentValues();
                values.put(COL_CLT, clientb.getClt());
                values.put(COL_PRENOM, clientb.getPrenom());
                values.put(COL_NOM, clientb.getNom());
                values.put(COL_DATE_NAIS, clientb.getDate_nais());
                values.put(COL_EMAIL, clientb.getEmail());
                values.put(COL_LOGIN, clientb.getLogin());
                values.put(COL_MDP, clientb.getMdp());
                return bdd.update(TABLE_CLIENTSB, values, COL_ID + " = " +id, null);
            }
     
     
     
     
     
            public int removeClientbWithID(int id){
                //Suppression d'un client de la BDD grâce à l'ID
                return bdd.delete(TABLE_CLIENTSB, COL_ID + " = " +id, null);
            }
     
            public Clientb getClientbWithLogin(String login){
                //Récupère dans un Cursor les valeur correspondant à un client contenu dans la BDD (ici on sélectionne le client grâce à son nom)
                Cursor c = bdd.query(TABLE_CLIENTSB, new String[] {COL_ID,COL_CLT, COL_PRENOM, COL_NOM,COL_DATE_NAIS,COL_EMAIL, COL_LOGIN, COL_MDP}, COL_LOGIN + " LIKE \"" + login +"\"", null, null, null, null);
                return cursorToClientb(c);
            }
            public Compte getSdeWithNCP(String NCP){
                //Récupère dans un Cursor les valeur correspondant à un client contenu dans la BDD (ici on sélectionne le client grâce à son nom)
                Cursor c = bdd.query(TABLE_CLIENTSB2, new String[] {COL_IDC,COL_NCP,COL_CLC,COL_INTI,COL_DOU,COL_SDE,COL_CLI}, COL_NCP + " LIKE \"" + NCP +"\"", null, null, null, null);
                return cursorToCompte(c);
            }
     
     
            //Cette méthode permet de convertir un cursor en un client
            private Clientb cursorToClientb(Cursor c){
                //si aucun élément n'a été retourné dans la requête, on renvoie null
                if (c.getCount() == 0)
                    return null;
     
                //Sinon on se place sur le premier élément
                c.moveToFirst();
                //On créé un livre
                Clientb clientb = new Clientb();
                //on lui affecte toutes les infos grâce aux infos contenues dans le Cursor
                clientb .setId(c.getInt(NUM_COL_ID));
                clientb .setClt(c.getString(NUM_COL_CLT));
                clientb .setPrenom(c.getString(NUM_COL_PRENOM));
                clientb .setNom(c.getString(NUM_COL_NOM));
                clientb .setDate_nais(c.getString(NUM_COL_DATE_NAIS));
                clientb .setEmail(c.getString(NUM_COL_EMAIL));
                clientb .setLogin(c.getString(NUM_COL_LOGIN));
                clientb .setMdp(c.getString(NUM_COL_MDP));
                //On ferme le cursor
                c.close();
     
                //On retourne le client
                return clientb;
            }
     
     
     
            //Cette méthode permet de convertir un cursor en un client
                    private Compte cursorToCompte(Cursor c){
                        //si aucun élément n'a été retourné dans la requête, on renvoie null
                        if (c.getCount() == 0)
                            return null;
     
                        //Sinon on se place sur le premier élément
                        c.moveToFirst();
                        //On créé un livre
                        Compte compte = new Compte();
                        //on lui affecte toutes les infos grâce aux infos contenues dans le Cursor
                        compte  .setId(c.getInt(NUM_COL_IDC));
                        compte  .setNcp(c.getString(NUM_COL_NCP));
                        compte  .setClc(c.getInt(NUM_COL_CLC));
                        compte  .setInti(c.getString(NUM_COL_INTI));
                        compte  .setDou(c.getString(NUM_COL_DOU));
                        compte  .setSde(c.getInt(NUM_COL_SDE));
                        compte  .setCli(c.getInt(NUM_COL_CLI));
     
                        //On ferme le cursor
                        c.close();
     
                        //On retourne le client
                        return compte;
                    }
            public static String getDateFromDatePicker(DatePicker dp) {
                return dp.getYear() + "-" + dp.getMonth() + 1 +  "-" + dp.getDayOfMonth();
            }
     
     
            public boolean Login(String LOGIN, String MDP) throws SQLException  
            { 
                Cursor mCursor = bdd.rawQuery("SELECT * FROM " + TABLE_CLIENTSB + " WHERE LOGIN=? AND MDP=?", new String[]{LOGIN,MDP}); 
                if (mCursor != null) {            
                    if(mCursor.getCount() > 0) 
                    { 
                        return true; 
                    } 
                } 
             return false; 
            } 
     
            public boolean Auth_compte(String NCP) throws SQLException  
            { 
                Cursor mCursor = bdd.rawQuery("SELECT * FROM " + TABLE_CLIENTSB2 + " WHERE NCP=?", new String[]{NCP}); 
                if (mCursor != null) {            
                    if(mCursor.getCount() > 0) 
                    { 
                        return true; 
                    } 
                } 
             return false; 
            } 
     
     
     
     
            //chaho
     
     public Cursor ConsultationSolde(String loginAut,String numcpte){
     
                // bdd.execSQL(" FOREIGN_KEYS PRAGMA = ON ");
                 String Query = " select " + MaBaseSQLite.TABLE_CLIENTSB2 + " . " +MaBaseSQLite.COL_SDE + " AS SDE"+
     
     
                " from " + MaBaseSQLite.TABLE_CLIENTSB2 +
                 " where " + MaBaseSQLite.TABLE_CLIENTSB + " . "+ MaBaseSQLite.COL_NCP +  " = '" + numcpte + "'"   
                + " and " + MaBaseSQLite.TABLE_CLIENTSB + " . "+ MaBaseSQLite.COL_LOGIN + " = '" + loginAut + "'"
                 ;
     
     
     
     
     
     
     
                   // + " C INNER JOIN " + TABLE_AEROPORT_DEPART + " U ON C.id_aero_dep = U.id_aero " +
                           // " WHERE U.id_aero = 1";
                 Cursor mCursor = bdd.rawQuery(Query, null);
                 if(mCursor == null || mCursor.getCount() == 0){
                      System.out.println("null");
                  }
                  return mCursor;
     
     
     
     
               }
     
     
     
     
     
    }

  2. #2
    Expert éminent

    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Février 2007
    Messages
    4 253
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2007
    Messages : 4 253
    Points : 7 618
    Points
    7 618
    Billets dans le blog
    3
    Par défaut
    Heu... ya pas comme un problème là:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    datasource = new ClientsbBDD(this);
     
              datasource.open();
     
               datasource.close();
    Du coup, pas besoin de l'ouvrir non ?

    La fonction "affiche()" n'est pas appelée.
    N'oubliez pas de cliquer sur mais aussi sur si un commentaire vous a été utile !
    Et surtout

  3. #3
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2015
    Messages : 33
    Points : 15
    Points
    15
    Par défaut
    merci de me repondre.et oui je m'en suis rendu compte (erreur bete!!!)

    j'ai fais quelques modifications mnt j'ai un forceclose voila ce que di le logcat

    d'apres l'erreur j comprends quil ne me récupère pas le LOGIN (where client.LOGIN="null" and NCP="77")(le 77 c'est la valeur que j'ai saisi lors de l'authentification avec le numero de compte NCP)

    je ne sais pas comment corriger cette erreur de syntaxe (sytax error)
    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
     
    04-15 09:23:36.534: E/AndroidRuntime(219): Uncaught handler: thread main exiting due to uncaught exception
    04-15 09:23:36.594: E/AndroidRuntime(219): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.SoldeCompte}: android.database.sqlite.SQLiteException: near "andcompte": syntax error: , while compiling:  select compte . SDE AS SDE from compte where client . LOGIN = 'null' and compte . NCP = '77'andcompte . CLI = client . CLT
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.os.Handler.dispatchMessage(Handler.java:99)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.os.Looper.loop(Looper.java:123)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.app.ActivityThread.main(ActivityThread.java:4363)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at java.lang.reflect.Method.invokeNative(Native Method)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at java.lang.reflect.Method.invoke(Method.java:521)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at dalvik.system.NativeStart.main(Native Method)
    04-15 09:23:36.594: E/AndroidRuntime(219): Caused by: android.database.sqlite.SQLiteException: near "andcompte": syntax error: , while compiling:  select compte . SDE AS SDE from compte where client . LOGIN = 'null' and compte . NCP = '77'andcompte . CLI = client . CLT
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.database.sqlite.SQLiteProgram.native_compile(Native Method)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:49)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1221)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1194)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at com.example.app.ClientsbBDD.ConsultationSolde(ClientsbBDD.java:259)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at com.example.app.SoldeCompte.afffiche(SoldeCompte.java:79)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at com.example.app.SoldeCompte.onCreate(SoldeCompte.java:58)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    04-15 09:23:36.594: E/AndroidRuntime(219):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
    04-15 09:23:36.594: E/AndroidRuntime(219):  ... 11 more

  4. #4
    Expert confirmé
    Avatar de Hephaistos007
    Profil pro
    Enseignant Chercheur
    Inscrit en
    Décembre 2004
    Messages
    2 493
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Enseignement

    Informations forums :
    Inscription : Décembre 2004
    Messages : 2 493
    Points : 4 166
    Points
    4 166
    Par défaut
    Cela semble être tout bêtement une erreur SQL : NCP = '77'andcompte . CLI = client au lieu de NCP = '77' and compte . CLI = client. A toi de voir à quel moment tes concaténations de chaines ont produit cette coquille.
    Il vaut mieux mobiliser son intelligence sur des conneries que mobiliser sa connerie sur des choses intelligentes --- devise SHADOKS

    Kit de survie Android : mon guide pour apprendre à programmer sur Android, mon tutoriel sur les web services et enfin l'outil en ligne pour vous faire gagner du temps - N'oubliez pas de consulter la FAQ Android

  5. #5
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2015
    Messages : 33
    Points : 15
    Points
    15
    Par défaut
    j ai corrigé les erreurs de syntaxe ,
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    public Cursor ConsultationSolde(String loginAut,String numcpte){
     
    			// bdd.execSQL(" FOREIGN_KEYS PRAGMA = ON ");
    			 String Query = " select " + MaBaseSQLite.TABLE_CLIENTSB2 + " . " +MaBaseSQLite.COL_SDE + " AS SDE"+
     
     
    			" from " + MaBaseSQLite.TABLE_CLIENTSB2+" , "+ MaBaseSQLite.TABLE_CLIENTSB+ 
    			 " where "+ MaBaseSQLite.TABLE_CLIENTSB + " . "+ MaBaseSQLite.COL_LOGIN + " = '" + loginAut + "'"   
    			+ " and " + MaBaseSQLite.TABLE_CLIENTSB2 + " . "+ MaBaseSQLite.COL_NCP +  " = '" + numcpte + "'"
    			 +" and "+
    			 MaBaseSQLite.TABLE_CLIENTSB2 + " . "+ MaBaseSQLite.COL_CLI +  " = "+MaBaseSQLite.TABLE_CLIENTSB + " . "+ MaBaseSQLite.COL_CLT 
    			 ;
    mais j ai tjr une erreur voila 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
    23
    24
    25
    04-15 18:45:59.041: E/AndroidRuntime(314): Uncaught handler: thread main exiting due to uncaught exception
    04-15 18:45:59.061: E/AndroidRuntime(314): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.SoldeCompte}: java.lang.IllegalArgumentException: column '_id' does not exist
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.app.ActivityThread.access$2200(ActivityThread.java:119)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.os.Handler.dispatchMessage(Handler.java:99)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.os.Looper.loop(Looper.java:123)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.app.ActivityThread.main(ActivityThread.java:4363)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at java.lang.reflect.Method.invokeNative(Native Method)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at java.lang.reflect.Method.invoke(Method.java:521)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at dalvik.system.NativeStart.main(Native Method)
    04-15 18:45:59.061: E/AndroidRuntime(314): Caused by: java.lang.IllegalArgumentException: column '_id' does not exist
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.widget.CursorAdapter.init(CursorAdapter.java:111)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.widget.CursorAdapter.<init>(CursorAdapter.java:90)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.widget.ResourceCursorAdapter.<init>(ResourceCursorAdapter.java:47)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:88)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at com.example.app.SoldeCompte.afffiche(SoldeCompte.java:71)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at com.example.app.SoldeCompte.onCreate(SoldeCompte.java:58)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
    04-15 18:45:59.061: E/AndroidRuntime(314): 	... 11 more

  6. #6
    Expert éminent

    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Février 2007
    Messages
    4 253
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2007
    Messages : 4 253
    Points : 7 618
    Points
    7 618
    Billets dans le blog
    3
    Par défaut
    Bien relire la documentation de CursorAdapter

    En particulier l'overview:
    dapter that exposes data from a Cursor to a ListView widget.

    The Cursor must include a column named "_id" or this class will not work. Additionally, using MergeCursor with this class will not work if the merged Cursors have overlapping values in their "_id" columns.

    Et je rajouterai, que la construction manuelle de SQL (en particulier à partir de variables venant de l'exterieur comme des EditText et/ou des paramètres dans une API) est fortément déconseillé.... Imaginez le cas ou une telle variable contiendrait, par exemple:
    " or exists (select null from delete users)"
    Bon... bref, la fonction sqlQuery contient un tableau de paramètres, il faut l'utiliser pour passer les paramètres...
    N'oubliez pas de cliquer sur mais aussi sur si un commentaire vous a été utile !
    Et surtout

  7. #7
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2015
    Messages : 33
    Points : 15
    Points
    15
    Par défaut
    j ai cru que le pb etait dans la colonne id ,alr j ai changé dans la base de données ID en _id comme indiqué dans l'erreur , sans resultat. c'est la meme erreur qui revient

  8. #8
    Expert éminent

    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Février 2007
    Messages
    4 253
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2007
    Messages : 4 253
    Points : 7 618
    Points
    7 618
    Billets dans le blog
    3
    Par défaut
    peut importe le vrai nom de la colonne dans la table....

    Mais il faut que le *cursor* ait une colonne nommée _id

    Ca peut être par exemple:

    select toto as _id, sum(amounts) from xxxxx;

    dans ce cas, la colonne "toto" sera considée comme _id du cursor.

    Hors là:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    String Query = " select " + MaBaseSQLite.TABLE_CLIENTSB2 + " . " +MaBaseSQLite.COL_SDE + " AS SDE"+ ...
    je ne vois qu'une seule colonne ... et pas nommée "_id" ....
    N'oubliez pas de cliquer sur mais aussi sur si un commentaire vous a été utile !
    Et surtout

  9. #9
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2015
    Messages : 33
    Points : 15
    Points
    15
    Par défaut
    j ai corrigé ça, et j'ai plus cette erreur 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
    23
    24
    25
    26
     
     public Cursor ConsultationSolde(String loginAut,String numcpte){
     
    			// bdd.execSQL(" FOREIGN_KEYS PRAGMA = ON ");
    			 String Query = " select " + MaBaseSQLite.TABLE_CLIENTSB2 + " . " +MaBaseSQLite.COL_SDE + " AS SDE"+","+ MaBaseSQLite.TABLE_CLIENTSB2 + " . " + MaBaseSQLite.COL_IDC + " AS _id" +
     
     
    			" from " + MaBaseSQLite.TABLE_CLIENTSB2+" , "+ MaBaseSQLite.TABLE_CLIENTSB+ 
    			 " where "+ MaBaseSQLite.TABLE_CLIENTSB + " . "+ MaBaseSQLite.COL_LOGIN + " = '" + loginAut + "'"   
    			+ " and " + MaBaseSQLite.TABLE_CLIENTSB2 + " . "+ MaBaseSQLite.COL_NCP +  " = '" + numcpte + "'"
    			 +" and "+
    			 MaBaseSQLite.TABLE_CLIENTSB2 + " . "+ MaBaseSQLite.COL_CLI + " = " + MaBaseSQLite.TABLE_CLIENTSB + " . " + MaBaseSQLite.COL_CLT 
    			 ;
     
     
     
    			 Cursor mCursor = bdd.rawQuery(Query, null);
    			 if(mCursor == null || mCursor.getCount() == 0){
    				  System.out.println("null");
    			  }
    			  return mCursor;
     
     
     
     
    		   }

    mais rien n est affiché ds la listview de l'activité solde compte (je vous reposte son code)
    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
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    package com.example.app;
     
     
     
    import android.content.Intent;
    import android.database.Cursor;
    import android.os.Bundle;
    import android.support.v7.app.ActionBarActivity;
    import android.widget.ListView;
    import android.widget.SimpleCursorAdapter;
     
    public class SoldeCompte extends ActionBarActivity {
    	private ClientsbBDD datasource;
     
     
     
    //ClientsbBDD datasource=new ClientsbBDD(this);
     
    	ListView lv1;
    	// TextView solde;
     
     
     
    	String AGEC_SOLDE;
        String AGECONS_SOLDE;
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_solde_compte);
    		//solde = (TextView)findViewById(R.id.solde);
     
    		  Intent i = getIntent();
     
    		  // Bundle extras= getIntent().getExtras();
     
    	        AGEC_SOLDE = i.getStringExtra(Ex_conn.AGEC);
     
    	        AGECONS_SOLDE = i.getStringExtra(Consultation.AGECONS);
     
     
     
     
     
    	    // Puis on récupère l'âge donné dans l'autre activité, ou 0 si cet extra n'est pas dans l'intent
     
     
     
    	  // text.setText(age8 );
    	    // S'il ne s'agit pas de l'âge par défaut
    	   // if(age != 0)
    	      // Traiter l'âge
    	     // age = 2;
     
     
    		   datasource = new ClientsbBDD(this);
     
    		  datasource.open();
    		afffiche();
    		   datasource.close();
     
     
    	}
     
    	 public void afffiche(){
    		 lv1=(ListView)findViewById(R.id.lv1);
    	    	//récuperer les donnnée
    	    	Cursor c = datasource.ConsultationSolde(AGEC_SOLDE,AGECONS_SOLDE);
    	    	//s'occuper du cursseur par exemple pr libérer la memoire 
    	    	startManagingCursor(c);
    	    	//et la les données récupérer qui seront afficher dns les champs de list_item
    	    	SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
    	    	R.layout.list_item,c,new String[]{"SDE"},
    	    	new int[]{R.id.solde});
    	    	lv1.setAdapter(adapter);
    	    }
     
     
    	/*public void afffiche(){
    	    	Cursor c = datasource.ConsultationSolde(key,key2);
     
    	    	SimpleCursorAdapter adapter = new SimpleCursorAdapter(
    	    			this,
    	    			R.layout.activity_solde_compte,
    	    			c, 
    	    			new String[]{"SDE"},
    	    			new int[]{R.id.solde});
    	    	//lv1.setAdapter(adapter);
    	    	//setListAdapter(adapter);
    	    	//this.setListAdapter(adapter);
    	    }*/
    	/*public void afffiche(){
    		int i=0,i1=0;
    	String[] mStrings = new String[i];
    	 Cursor c = datasource.ConsultationSolde(key,key2);
         startManagingCursor(c);
        //on créer le tableau de string avec les pseudos des joueurs
        while(!c.isAfterLast()) {
            mStrings[i1] =  c.getString(c.getColumnIndex("SDE"));
            i1++;
            c.moveToNext();
        }
        c.close();
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, mStrings);
        //Récupération du ListView présent l'IHM
        ListView lv1 = (ListView)findViewById(R.id.lv1);
        //On passe nos données au composant ListView
        lv1.setAdapter(adapter);
     
     
    	}*/
     
     
     
     
    }
    je fais appel dans afffiche au curseur de la bdd ConsultationSolde
    je n ai pas d'erreur dans le logcat, mais par contre j'ai ça
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    04-17 15:19:01.253: I/ActivityManager(63): Starting activity: Intent { cmp=com.example.app/.SoldeCompte (has extras) }
    04-17 15:19:01.343: I/System.out(14780): null
    donc d'apres moi le "null" vient de l'execution de cette instruction
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    if(mCursor == null || mCursor.getCount() == 0){
    				  System.out.println("null");
    mais cela veut-il dire quil n a rien pu récupérer de la bdd??
    MERCI

  10. #10
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Avril 2015
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2015
    Messages : 33
    Points : 15
    Points
    15
    Par défaut
    j'ai pu régler mon pb , merci (erreur sur les constantes récupérées avec l'intent)

Discussions similaires

  1. Réponses: 16
    Dernier message: 27/10/2006, 16h12
  2. affichage de donnée dans LISTVIEW
    Par k_boy dans le forum VC++ .NET
    Réponses: 16
    Dernier message: 13/09/2006, 13h13
  3. [C#] Touche Tab, Affichage du curseur dans un RichText Box.
    Par schizette dans le forum Windows Forms
    Réponses: 1
    Dernier message: 19/07/2006, 12h16
  4. Probleme d'affichage du curseur dans un chp texte avec firef
    Par dadovb dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 20/10/2005, 12h31
  5. [C#] Affichage resultat de requete dans 2 Labels
    Par kenzo080 dans le forum ASP.NET
    Réponses: 8
    Dernier message: 02/06/2004, 20h07

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