listview 설정부분
final ExpandableListView listView = (ExpandableListView)v.findViewById(R.id.listview);
// listView .setGroupIndicator(null); // child onoff 화살표를 없애려면 null 설정.
// StateListDrawable groupIndicator = (StateListDrawable)getResources().getDrawable(R.drawable.arrow_sel);
// myListView.setGroupIndicator(groupIndicator);
MyAdapter myAdapter= new MyAdapter(this);
myListView.setAdapter(myAdapter);
custom adapter 부분
private class MyAdapter extends BaseExpandableListAdapter{
private LayoutInflater mInflater;
private Context mContext;
public MyAdapter(Context context) {
mContext = context;
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public MyClass getChild(int arg0, int arg1) {
return null /*child 부분 설정해놓으세요.*/;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return childPosition;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
MyClass item = this.getChild(groupPosition, childPosition);
if(convertView == null)convertView = mInflater.inflate(R.layout.item_child, null);
if(item != null){
TextView content = (TextView)convertView.findViewById(R.id.child);
}
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
// TODO Auto-generated method stub
return 1;
}
@Override
public Object getGroup(int groupPosition) {
// TODO Auto-generated method stub
return null /*getGroup 부분설정해놓으세요*/;
}
@Override
public int getGroupCount() {
// TODO Auto-generated method stub
return null /*getGroupCount부분설정해놓으세요*/;
}
@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) {
MyClass item = myClassListData.get(groupPosition);
if(convertView == null)convertView = mInflater.inflate(R.layout.group, null);
if(item != null){
TextView content = (TextView)convertView.findViewById(R.id.group);
}
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return true;
}
xml부분. 일부
<ExpandableListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@drawable/arrow_sel"
android:indicatorLeft="0px"
android:indicatorRight="0px"
android:divider="#000000"
android:dividerHeight="1px"
android:childDivider="#000000"
></ExpandableListView>
|