1
我想讓我的類顯示數據庫中的所有數據。在當前時間它,我只顯示了一組數據,這將是冠軍,我試圖改變他的代碼是什麼我認爲會顯示所有獲取數據庫行中的所有數據以顯示Android SQLite
public class WorkoutProgress extends ListActivity {
private DataBaseHelper datasource;
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.progress);
datasource = new DataBaseHelper(this);
datasource.open();
fillData();
datasource.close();
}
private void fillData() {
// Get all of the notes from the database and create the item list
Cursor c = datasource.getAllTitles();
startManagingCursor(c);
String[] from = new String[] { DataBaseHelper.KEY_TITLE,DataBaseHelper.KEY_ISBN, DataBaseHelper.KEY_PUBLISHER };
int[] to = new int[] { R.id.text1 };
// Now create an array adapter and set it to display using our row
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
setListAdapter(notes);
}
}
我想的代碼我需要改變的是數據這條線
String[] from = new String[] { DataBaseHelper.KEY_TITLE};
向該線
String[] from = new String[] { DataBaseHelper.KEY_TITLE,DataBaseHelper.KEY_ISBN, DataBaseHelper.KEY_PUBLISHER };
這是notes_row.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/text1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/text2"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/text3"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
,所以我也將增加更多的Textv在note_row中查看,然後將新的textViews放入'to'數組中? – 2012-04-03 14:22:02
@DarrenMurtagh是的,否則應該在哪裏顯示數據? – Luksprog 2012-04-03 14:23:40
當我將xml更改爲xml上面添加的內容時說有錯誤 – 2012-04-03 14:28:12