Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 从带有标头的expandablelistview检索原始适配器_Android_Expandablelistview - Fatal编程技术网

Android 从带有标头的expandablelistview检索原始适配器

Android 从带有标头的expandablelistview检索原始适配器,android,expandablelistview,Android,Expandablelistview,我将ExpandableListView与扩展BaseExpandableListAdapter的自定义适配器一起使用。 现在我想在可扩展列表中添加一个标题,因此我不需要使用apapter来获取元素的视图,而需要使用用标题“自动”创建的标题,这样我就不会获取IndexOutOfBoundsExceptions,因为现在标题是位于0位置的元素 在我的适配器不可扩展的其他地方,我只需要调用myList.getAdapter(),一切正常,但现在我需要获得扩展BaseExpandableListAda

我将ExpandableListView与扩展BaseExpandableListAdapter的自定义适配器一起使用。 现在我想在可扩展列表中添加一个标题,因此我不需要使用apapter来获取元素的视图,而需要使用用标题“自动”创建的标题,这样我就不会获取IndexOutOfBoundsExceptions,因为现在标题是位于0位置的元素

在我的适配器不可扩展的其他地方,我只需要调用myList.getAdapter(),一切正常,但现在我需要获得扩展BaseExpandableListAdapter的适配器,我找不到方法

myList = (ExpandableListView)findViewById(R.id.my_list);
myList .setGroupIndicator(null);
myList .setOnGroupClickListener(this);
myList .setOnChildClickListener(this);

//add a header
View addSummaryLayout = View.inflate(this, R.layout.add_summary, null); 
groupedMultimediaListView.addHeaderView(addSummaryLayout);  

myAdapter = new MyAdapter (this, uploadingMedias);
myList .setAdapter(myAdapter );
有时,我需要为myAdapter(extends BaseExpandableListAdapter)调用getChildView方法,但我不能直接使用myAdapter,因为该方法没有标头。我需要通过列表来完成它。我正试着通过getWrappedAdapter来做

HeaderViewListAdapter headerAdapter = ((HeaderViewListAdapter) myList .getAdapter());
((MyAdapter ) headerAdapter.getWrappedAdapter()).getChildView(0, i - 1, false, view, myList );
但它给了我一个ClassCastException,android.widget.ExpandableListConnector不能强制转换到MyAdapter

有人知道通过列表方法获取原始适配器的方法吗

谢谢您

来自


因此,请使用,
getExpandableListAdapter()
然后使用getChildView

谢谢!我没有看到警告,正在用另一个适配器发疯!太神奇了,我挠了很久的头。在使用自定义函数添加(CustomObject obj)时,使用自定义适配器强制转换getAdapter()不会导致问题,但不会刷新。救了我一天!
public ListAdapter getAdapter ()

Added in API level 1
This method should not be used, use getExpandableListAdapter().