Bonjour,
j’essaie d'afficher des informations par le biais d'une listview et de Simple Cursor Adapter, mais mon écran n'affiche rien et je n'ai pas d'erreur sur le logCat.
logCat
IHM
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 08-21 22:03:32.777: D/AndroidRuntime(240): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< 08-21 22:03:32.787: D/AndroidRuntime(240): CheckJNI is ON 08-21 22:03:33.320: D/AndroidRuntime(240): --- registering native functions --- 08-21 22:03:33.857: D/ddm-heap(240): Got feature list request 08-21 22:03:34.287: I/ActivityManager(51): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.virtualbudget/.MainActivity } 08-21 22:03:34.357: D/AndroidRuntime(240): Shutting down VM 08-21 22:03:34.357: D/dalvikvm(240): DestroyJavaVM waiting for non-daemon threads to exit 08-21 22:03:34.357: D/dalvikvm(240): DestroyJavaVM shutting VM down 08-21 22:03:34.357: D/dalvikvm(240): HeapWorker thread shutting down 08-21 22:03:34.357: D/dalvikvm(240): HeapWorker thread has shut down 08-21 22:03:34.357: D/jdwp(240): JDWP shutting down net... 08-21 22:03:34.367: I/dalvikvm(240): Debugger has detached; object registry had 1 entries 08-21 22:03:34.386: D/dalvikvm(240): VM cleaning up 08-21 22:03:34.407: E/AndroidRuntime(240): ERROR: thread attach failed 08-21 22:03:34.427: I/ActivityManager(51): Start proc com.virtualbudget for activity com.virtualbudget/.MainActivity: pid=248 uid=10028 gids={} 08-21 22:03:34.447: D/dalvikvm(240): LinearAlloc 0x0 used 639500 of 5242880 (12%) 08-21 22:03:34.719: D/ddm-heap(248): Got feature list request 08-21 22:03:35.697: I/ActivityManager(51): Displayed activity com.virtualbudget/.MainActivity: 1280 ms (total 1280 ms) 08-21 22:03:38.406: I/ActivityManager(51): Starting activity: Intent { cmp=com.virtualbudget/.LesComptes (has extras) } 08-21 22:03:38.556: I/System.out(248): cursor non null 08-21 22:03:38.566: I/System.out(248): cursor ok3 08-21 22:03:38.566: I/System.out(248): cursor ok4 08-21 22:03:39.061: I/ActivityManager(51): Displayed activity com.virtualbudget/.LesComptes: 612 ms (total 612 ms)
layout principal
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 db = new DBAdapter(getApplicationContext()); db.open(); bundle = this.getIntent().getExtras(); utilisateur = new Utilisateur(); compte = new Compte(); AddListenerOnBtnAjout(); ListView(); } public void ListView(){ //On récupère les données du Bundle idUtilisateur = (Integer) bundle.get("COL_ID"); //selectionne liste de compte de l'utilisateur cursor = db.SelectDesComptesUtilisateur(idUtilisateur); if(cursor.getCount() != 0){ cursor.moveToFirst(); startManagingCursor(cursor); System.out.println("cursor non null"); try{ SimpleCursorAdapter adapte = new SimpleCursorAdapter(this, R.layout.listeview_compte, cursor, new String[]{"COL_BANK","COL_TITRE","COL_TOTAL"},new int[]{R.id.TvBank,R.id.TvNom,R.id.TvMontant}); System.out.println("cursor ok3"); LvCompte = (ListView)findViewById(android.R.id.list); System.out.println("cursor ok4"); LvCompte.setAdapter(adapte); }catch(Error e){ Log.d("tag", "BOUM !", e); }finally{ cursor.close(); }
layout secondaire (contenu de ma liste)
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 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" > <ListView android:id="@android:id/list" android:layout_width="wrap_content" android:layout_height="380dp" > </ListView> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:id="@+id/BtnAjout" style="?android:attr/buttonStyleSmall" android:layout_width="75dp" android:layout_height="48dp" android:layout_marginTop="3dp" android:layout_marginLeft="35dp" android:text="@string/ajout" android:textSize="12sp" /> <Button android:id="@+id/BtnSup" style="?android:attr/buttonStyleSmall" android:layout_width="75dp" android:layout_height="48dp" android:layout_marginLeft="22dp" android:layout_marginTop="10dp" android:text="@string/supprimer" android:textSize="12sp" /> <Button android:id="@+id/BtnApercu" style="?android:attr/buttonStyleSmall" android:layout_width="75dp" android:layout_height="48dp" android:layout_marginTop="10dp" android:layout_marginLeft="22dp" android:text="@string/apercu" android:textSize="12sp" /> </LinearLayout> </LinearLayout>
et enfin ma requete SQL
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 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" > <RadioButton android:id="@+id/RbtnSelect" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:padding="10dp" android:layout_marginLeft="10dp" android:text="@string/RbtnSelect" /> <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:paddingLeft="10dp" android:layout_weight="1" > <TextView android:id="@+id/TvBank" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="@string/bank" /> <TextView android:id="@+id/TvNom" android:layout_width="wrap_content" android:layout_height="fill_parent" android:textStyle="bold" android:text="@string/nom" /> </LinearLayout> <TextView android:id="@+id/TvMontant" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:padding="10dp" android:text="@string/montant" /> </LinearLayout>
Mon cursor n'est pas nul, j'ai bien des infos dans ma base de donnée, si quelqu'un a une idée ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 public Cursor SelectDesComptesUtilisateur(int idUtilisateur){ db = database.getReadableDatabase(); String query = " SELECT COL_ID_COMPTE AS _id, COL_BANK, COL_TITRE, COL_TOTAL FROM " + BDD.TABLE_COMPTES + " WHERE COL_ID_UTILISATEUR = ? "; String id = Integer.toString(idUtilisateur); Cursor mCursor = db.rawQuery(query,new String [] {id}); return mCursor; }
Partager