SimpleCursorTreeAdapterでexpandableListを作成しようとしていますが、リストがグループ化されず、すべての子要素がグループ要素として繰り返されます。expandableList問題
マイ件のデータがKEY_ROWID、KEY_NAME、KEY_EMAIL、KEY_ILID、KEY_KURUMID、KEY_BOLGEID
私の件のデータとして形成されている:
(db,"Asli", "[email protected]", 1, 1, 1);
(db,"Osman Can", "[email protected]", 1, 1, 1);
(db,"Abuzer Kadayif", "[email protected]", 1, 2, 1);
(db,"Emre", "[email protected]", 1, 3, 2);
(db,"Deniz", "[email protected]", 1, 4, 2);
(db,"Simon Garfunkel", "[email protected]", 1, 5, 0);
(db,"Eric Clapton", "[email protected]", 1, 6, 0);
(db,"Neil Young", "[email protected]", 1, 5, 0);
そして、これが私のコードです:
String sqlString = "SELECT * " + " FROM " + Items.DATABASE_TABLE;
Cursor mCursor = db.rawQuery(sqlString, null);
SimpleCursorTreeAdapter mAdapter = new SimpleCursorTreeAdapter(this,
mCursor, R.layout.row, R.layout.exprow,
//createGroupList(),
new String[] { Items.KEY_BOLGEID },
new int[] { R.id.txtItem },
R.layout.exprow, R.layout.exprow,
new String[] { Items.KEY_EMAIL,Items.KEY_NAME }, new int[] { R.id.dscItem, R.id.manuItem }) {
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
String tempGroup = groupCursor.getString(groupCursor
.getColumnIndex(Items.KEY_BOLGEID));
DbHelper dbh = new DbHelper(BrowseActivity.this);
SQLiteDatabase db = dbh.getWritableDatabase();
String sqlString = "SELECT " + Items.KEY_ROWID + ", "
+ Items.KEY_EMAIL + ", " + Items.KEY_NAME + ", "
+ Items.KEY_KURUMID + ", " + Items.KEY_BOLGEID + ", "
+ Items.KEY_ILID + " FROM " + Items.DATABASE_TABLE
+ " WHERE " + Items.KEY_BOLGEID + "= " + tempGroup
;
Cursor mCursor = db.rawQuery(sqlString, null);
return mCursor;
}
};
browseView.setAdapter(mAdapter);
}
私の結果:
Group 1:
(db,"Asli", "[email protected]", 1, 1, 1);
(db,"Osman Can", "[email protected]", 1, 1, 1);
(db,"Abuzer Kadayif", "[email protected]", 1, 2, 1);
Group 2:
(db,"Emre", "[email protected]", 1, 3, 2);
(db,"Deniz", "[email protected]", 1, 4, 2);
Group 3:
(db,"Simon Garfunkel", "[email protected]", 1, 5, 0);
(db,"Eric Clapton", "[email protected]", 1, 6, 0);
(db,"Neil Young", "[email protected]", 1, 5, 0);
しかし、それは1 2回グループ2 3回グループ0
3倍のグループであると私はgroupCursorのSQLを変更しようとしましたが、それはクラッシュします。
これにはまだ方向性が必要ですか? – Barak
私はこれと同様のことをしていますhttp://stackoverflow.com/questions/10611927/simplecursortreeadapter-and-cursorloader – toobsco42