WEB开发网
开发学院手机开发Android 开发 Android ExpandableListView / ExpandableListAct... 阅读

Android ExpandableListView / ExpandableListActivity 使用及数据更新

 2010-08-21 06:33:00 来源:WEB开发网   
核心提示:}@Overridepublic View getChildView(int groupPosition, int childPosition,boolean isLastChild, View convertView, ViewGroup parent) {// TODO Auto-generated method

}

@Override

public View getChildView(int groupPosition, int childPosition,

boolean isLastChild, View convertView, ViewGroup parent) {

// TODO Auto-generated method stub

String string = child.get(groupPosition).get(childPosition);

return getGenericView(string);

}

//group method stub

@Override

public Object getGroup(int groupPosition) {

// TODO Auto-generated method stub

return group.get(groupPosition);

}

@Override

public int getGroupCount() {

// TODO Auto-generated method stub

return group.size();

}

@Override

public long getGroupId(int groupPosition) {

// TODO Auto-generated method stub

return groupPosition;

}

@Override

public View getGroupView(int groupPosition, boolean isExpanded,

View convertView, ViewGroup parent) {

// TODO Auto-generated method stub

String string = group.get(groupPosition);

return getGenericView(string);

}

//View stub to create Group/Children 's View

public TextView getGenericView(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);

// Center the text vertically

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

// Set the text starting position

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

text.setText(s);

return text;

}

@Override

public boolean hasStableIds() {

// TODO Auto-generated method stub

return false;

上一页  1 2 3 4 5 6 7 8  下一页
赞助商链接