// 初始化赋值,assign:赋值,将数据库里的目录名存放到一级目录groups里
private void assign() {
// 查询目录
SQLiteDatabase sdbDatabase = openDatabase();
Cursor cursor = sdbDatabase.query("directory", new String[] { "id",
"name" }, null, null, null, null, null);
child = new String[cursor.getCount()][];
childID = new String[cursor.getCount()][];
listbook = new ArrayList<Map<String, Object>>();
groups = new String[cursor.getCount()];
int i = 0;
while (cursor.moveToNext()) {
byte[] buff = new byte[60]; // 定义一下足够大的数组
buff = cursor.getBlob(cursor.getColumnIndex("name"));
try {
directoryname = new String(buff, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
directoryid = cursor.getInt(cursor.getColumnIndex("id"));
groups[i] = directoryname; // 添加图书
Cursor cursor1 = sdbDatabase.query("book", new String[] { "id",
"name","lujing" }, "directory=?", new String[] { directoryid + "" },
null, null, null);
// child = new String[cursor.getCount()][];
child[i] = new String[cursor1.getCount()];
childID[i] = new String[cursor1.getCount()];
int b = 0;
String nametushu = "";
String ID = "";
while (cursor1.moveToNext()) {
byte[] buff1 = new byte[300]; // 定义一下足够大的数组
buff1 = cursor1.getBlob(cursor.getColumnIndex("name"));
try {
nametushu = new String(buff1, "UTF-8"); } catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
ID = cursor1.getString(cursor.getColumnIndex("id"));
childID[i][b] = ID;
child[i][b] = nametushu;
b++;
}
cursor1.close(); i++;
}
cursor.close();
sdbDatabase.close();
} // 初始化赋值, 将一级目录groups里的数值打包成Treeadapter,添加到expandableList里
public void exlistassign() {
assign();
groupslist = getData();
Treeadapter = new TreeViewAdapter(this,
TreeViewAdapter.PaddingLeft >> 1);
Treeadapter.RemoveAll();
Treeadapter.notifyDataSetChanged();
List<TreeViewAdapter.TreeNode> treeNode = Treeadapter.GetTreeNode();
for (int i = 0; i < groups.length; i++) {
TreeViewAdapter.TreeNode node = new TreeViewAdapter.TreeNode();
node.parent = groups[i];
if (child[i] != null) {
for (int ii = 0; ii < child[i].length; ii++) {
node.childs.add(child[i][ii]);
}
}
treeNode.add(node);
}
Treeadapter.UpdateTreeNode(treeNode);
expandableList.setAdapter(Treeadapter);

//阅读图书
expandableList.setOnChildClickListener(new OnChildClickListener() {
public boolean onChildClick(ExpandableListView arg0, View arg1,
int parent, int children, long arg4) {

String id = childID[parent][children];
Intent it = new Intent(BookActivity.this,ReaderActivity.class);
Bundle bd = new Bundle();
bd.putString("id", id);
it.putExtras(bd);
startActivity(it); return false;
}
}); }断点调试的结果是 String id = childID[parent][children];这句代码里的[parent][children]的数据都为0,想知道到底是哪里出了错,运行结果是跳转的页面变成黑屏,LogCat则一直进行无限量循环运算。
由于本人是新手,所以不知道该提供什么来提问,只好先提供这些了!