0
我有一個java類正在從android sqllite中的數據庫中獲取兩列。是否可以爲兩列設置不同的textview佈局屬性?如果是的話,我希望知道要走的路。如何爲不同的列設置不同的文本視圖
這就是我迄今爲止所做的。
我TextView的佈局屬性
<----Main Title---->
<TextView
android:id="@+id/firstLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:textSize="14sp"
android:textStyle="bold" />
<!-- Subtitle-->
<TextView
android:id="@+id/secondLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@id/firstLine"
android:layout_below="@id/firstLine"
android:textSize="12sp"
/>
這是從數據庫
/**
* DISPLAY RESULTS
*/
//Create Cursor object to read notification from the table
Cursor c = db.rawQuery("SELECT ID,NOTIFICATIONS FROM notices order by ID desc", null);
//If Cursor is valid
if (c != null) {
Toast.makeText(Notification.this, "Query is valid", Toast.LENGTH_LONG).show();
//Move cursor to first row
if (c.moveToFirst()) {
do {
String Name = c.getString(c.getColumnIndex("NOTIFICATIONS"));
int Ids = c.getInt(c.getColumnIndex("ID"));
//Add the notification to Arraylist 'results'
results.add(Name);
}while (c.moveToNext()); //Move to next row
}
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.notification_textview,R.id.firstLine, results);
// Assign adapter to ListView
listView.setAdapter(adapter);
quering我們的數據。在這種情況下,方法,我想了firstLine
TextView的性質爲Name
設置列和secondLine
textview屬性設置爲Ids
列。
感謝您的幫助。