그래서 내 DataGrid를 채울 수 있도록 Cursor를 구현하려고합니다 (SP와 Prepared Statement에 대해 callable을 사용해야 할 때 올바른 방법인지는 확실하지 않습니다) 이는 내가이 guide here 만든하지만 난AsyncTask에서 PreparedStatement에 대한 커서 구현
DataGridActivity.Itemnumber 추상적하지 얻고
내가 추상 메소드를 구현하는 방법을 잘 모르겠습니다 커서에서 추상 메소드의 응답 (번들)를 대체하지 않습니다 here as i normaly는 내 준비된 문장에 대해 getstring methode를 사용합니다. 어떻게 든이 있다면 내가 대신 내 그리드를 채우기 위해 그렇게하는 대신 당신은 Itemnumber
클래스의 마지막 메소드를 오버라이드 (override) 할 필요
Cursor csr = new Itemnumber();
//create DataTable object
DataTable dtDataSource = new DataTable();
//define column
dtDataSource.addAllColumns(new String[]{"column_1", "column_2","column_3", "column_4});
//create DataRow
DataTable.DataRow drRow;
//populate data from cursor into DataSource
if(csr.moveToFirst()){
do{
drRow = dtDataSource.newRow();
drRow.set("column_1", csr.getString(csr.getColumnIndex("field_1")));
drRow.set("column_2", csr.getString(csr.getColumnIndex("field_2")));
drRow.set("column_2", csr.getString(csr.getColumnIndex("field_3")));
drRow.set("column_4", csr.getString(csr.getColumnIndex("field_4")));
dtDataSource.add(drRow);
} while(csr.moveToNext());
csr.close();
}
/**
* Prepare the DataGrid
*/
//initialize DataGrid
DataGrid dg = (DataGrid)findViewById(R.id.datagrid);
//define column style, bond each DataGrid column by DataTable column
dg.addColumnStyles(new DataGrid.ColumnStyle[]{
new DataGrid.ColumnStyle(getString(R.string.ID), "column_1", 80),
new DataGrid.ColumnStyle(getString(R.string.ItemNumber), "column_2", 120),
new DataGrid.ColumnStyle(getString(R.string.Trashed), "column_3", 100),
new DataGrid.ColumnStyle(getString(R.string.Sold), "column_4", 150)
});
//set the DataTable as source
dg.setDataSource(dtDataSource);
//generate the DataGrid
dg.refresh();
예에 가까운 것이 될 듯하지 않았다 가져 오기 android.database.Cursor 이잖아; –