WEB开发网
开发学院手机开发Android 开发 Android ExpandableListActivity 使用 阅读

Android ExpandableListActivity 使用

 2010-05-29 06:02:00 来源:WEB开发网   
核心提示:TextView text = new TextView(activity);text.setLayoutParams(lp);text.setTextSize(20);text.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);text.setPadding(36,

TextView text = new TextView(activity);

text.setLayoutParams(lp);

text.setTextSize(20);

text.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);

text.setPadding(36, 0, 0, 0);

text.setText(s);

return text;

}

@Override

public Object getChild(int arg0, int arg1) {

// TODO Auto-generated method stub

return child.get(arg0).get(arg1);

}

@Override

public long getChildId(int arg0, int arg1) {

// TODO Auto-generated method stub

return arg1;

}

@Override

public int getChildrenCount(int arg0) {

// TODO Auto-generated method stub

return child.get(arg0).size();

}

@Override

public View getChildView(int arg0, int arg1, boolean arg2, View arg3,

ViewGroup arg4) {

// TODO Auto-generated method stub

return getChildViewStub(child.get(arg0).get(arg1).toString());

}

public TextView getChildViewStub(String s) {

// Layout parameters for the ExpandableListView

AbsListView.LayoutParams lp = new AbsListView.LayoutParams(

ViewGroup.LayoutParams.FILL_PARENT, 64);

TextView text = new TextView(activity);

text.setLayoutParams(lp);

text.setTextSize(20);

text.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);

text.setPadding(36, 0, 0, 0);

text.setText(s);

return text;

}

* 再完成与 Group 有关的函数列表

写道

public Object getGroup(int arg0)

public int getGroupCount()

public long getGroupId(int arg0)

public View getGroupView(int arg0, boolean arg1, View arg2,

ViewGroup arg3)

其实现如下:

Java代码

@Override

上一页  1 2 3 4 5 6 7  下一页

Tags:Android ExpandableListActivity 使用

编辑录入:coldstar [复制链接] [打 印]
赞助商链接