I have a piece of code which lists the content of my table, which contains a list of persons with various results...
I was able to get the values displayed in a Textview, like this :
1 Bob 0 0 0 0
2 Renee 0 0 0 0
3 Jason 0 0 0 0
4 Sandy 0 0 0 0
Is it possible to "style" it in order to have column content aligned? How may I set up the column "width"?!
Here is the code retrieving the data ...
try
{
db=openOrCreateDatabase("mydatabase",SQLiteDatabase.CREATE_IF_NECESSARY,null);
Cursor c= db.rawQuery("SELECT * FROM mytable",null);
TextView v=(TextView)findViewById(R.id.v);
c.moveToFirst();
String temp="";
while(! c.isAfterLast()) {
String s1=c.getString(0);
String s2=c.getString(1);
String s3=c.getString(2);
String s4=c.getString(3);
String s5=c.getString(4);
String s6=c.getString(5);
temp=temp+"\n"+s1+"\t"+s2;
c.moveToNext();
}
v.setText(temp);
}
catch(SQLiteException e)
{
}
}
... and puts it in the following Textview :
<TextView
android:id="@+id/v"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
Well, thank you very much in advance!
Aucun commentaire:
Enregistrer un commentaire