mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-11-30 03:08:12 +08:00
add some comment to expandablelistadapter.h,modify samples
This commit is contained in:
parent
5d0eb44e1a
commit
c74461c138
@ -80,9 +80,13 @@ int main(int argc,const char*argv[]){
|
||||
ExpandableListView*expLV = new ExpandableListView(0,0);
|
||||
MyBaseExpandableListAdapter*adapter=new MyBaseExpandableListAdapter(&app);
|
||||
std::vector<std::string>data;
|
||||
for(int i=0;i<6;i++)data.push_back(std::string("subitem")+std::to_string(i));
|
||||
for(int i=0;i<8;i++)data.push_back(std::string("subitem")+std::to_string(i));
|
||||
for(int j=0;j<30;j++)
|
||||
adapter->addGroupData(std::to_string(j),data);
|
||||
|
||||
expLV->setVerticalScrollBarEnabled(true);
|
||||
expLV->setOverScrollMode(View::OVER_SCROLL_ALWAYS);
|
||||
|
||||
expLV->setAdapter(adapter);
|
||||
w->addView(expLV);
|
||||
expLV->setOnChildClickListener([](ExpandableListView& parent, View& v, int groupPosition, int childPosition, long id){
|
||||
|
@ -49,7 +49,7 @@ private:
|
||||
std::vector<DataSetObserver*> mObservers;
|
||||
};
|
||||
|
||||
typedef Adapter ListAdapter,SpinnerAdapter;
|
||||
typedef Adapter ListAdapter,SpinnerAdapter,BaseAdapter;
|
||||
template<class T>
|
||||
class ArrayAdapter:public Adapter{
|
||||
public:
|
||||
|
@ -107,7 +107,37 @@ public:
|
||||
* @return the data child for the specified group
|
||||
*/
|
||||
virtual void* getGroup(int groupPosition)=0;
|
||||
/**
|
||||
* Get the type of group View that will be created by
|
||||
* {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
|
||||
* . for the specified group item.
|
||||
*
|
||||
* @param groupPosition the position of the group for which the type should be returned.
|
||||
* @return An integer representing the type of group View. Two group views should share the same
|
||||
* type if one can be converted to the other in
|
||||
* {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
|
||||
* . Note: Integers must be in the range 0 to {@link #getGroupTypeCount} - 1.
|
||||
* {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
|
||||
* @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
|
||||
* @see #getGroupTypeCount()
|
||||
*/
|
||||
virtual int getGroupType(int groupPosition)=0;/*====*/
|
||||
/**
|
||||
* <p>
|
||||
* Returns the number of types of group Views that will be created by
|
||||
* {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
|
||||
* . Each type represents a set of views that can be converted in
|
||||
* {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
|
||||
* . If the adapter always returns the same type of View for all group items, this method should
|
||||
* return 1.
|
||||
* </p>
|
||||
* This method will only be called when the adapter is set on the {@link AdapterView}.
|
||||
*
|
||||
* @return The number of types of group Views that will be created by this adapter.
|
||||
* @see #getChildTypeCount()
|
||||
* @see #getGroupType(int)
|
||||
*/
|
||||
|
||||
virtual int getGroupTypeCount()=0;/*====*/
|
||||
/**
|
||||
* Gets the data associated with the given child within the given group.
|
||||
@ -118,7 +148,38 @@ public:
|
||||
* @return the data of the child
|
||||
*/
|
||||
virtual void* getChild(int groupPosition, int childPosition)=0;
|
||||
/**
|
||||
* Get the type of child View that will be created by
|
||||
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
|
||||
* for the specified child item.
|
||||
*
|
||||
* @param groupPosition the position of the group that the child resides in
|
||||
* @param childPosition the position of the child with respect to other children in the group
|
||||
* @return An integer representing the type of child View. Two child views should share the same
|
||||
* type if one can be converted to the other in
|
||||
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
|
||||
* Note: Integers must be in the range 0 to {@link #getChildTypeCount} - 1.
|
||||
* {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
|
||||
* @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
|
||||
* @see #getChildTypeCount()
|
||||
*/
|
||||
virtual int getChildType(int groupPosition, int childPosition)=0;/*===*/
|
||||
/**
|
||||
* <p>
|
||||
* Returns the number of types of child Views that will be created by
|
||||
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
|
||||
* . Each type represents a set of views that can be converted in
|
||||
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
|
||||
* , for any group. If the adapter always returns the same type of View for
|
||||
* all child items, this method should return 1.
|
||||
* </p>
|
||||
* This method will only be called when the adapter is set on the {@link AdapterView}.
|
||||
*
|
||||
* @return The total number of types of child Views that will be created by this adapter.
|
||||
* @see #getGroupTypeCount()
|
||||
* @see #getChildType(int, int)
|
||||
*/
|
||||
|
||||
virtual int getChildTypeCount()=0;/*===*/
|
||||
/**
|
||||
* Gets the ID for the group at the given position. This group ID must be
|
||||
|
Loading…
Reference in New Issue
Block a user