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