Android // Afficher une variable dans un Textview
Bonjour!
J'ai ce bout de code qui va me retourner le nombre d'entrées de ma database, dans mon fichier Example.java:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public int getContactsCount() {
helper = new TaskDBHelper(Example.this);
SQLiteDatabase db = helper.getReadableDatabase();
String countQuery = "SELECT * FROM " + Playas.TABLE;
Cursor cursor = db.rawQuery(countQuery, null);
cursor.close();
// return count
return cursor.getCount();
}
public static void main(String[] args) {
Example example = new Example();
int a = example.getContactsCount();
System.out.println(a);
} |
Dans mon document example.xml, j'ai le TextViewsuivant :
Code:
1 2 3 4 5
|
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/total" /> |
Je souhaiterais afficher le résultat de la query dans ce Textview... Puis-je vous demander votre aide, svp?
Merci d'avance! :P
Baptiste457