我创建了一个自定义的可扩展列表适配器并在 getGroupView() 内部 和 getChildView() 我做了以下但收到错误:
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getActivity().getLayoutInflater()
.inflate(R.layout.expandable_list_parent_row_layout);
}
return convertView;
}
编译器告诉我它找不到方法 - getActivity()
有人可以帮忙吗?谢谢!
最佳答案
在适配器构造函数中,您将有一个 Context 参数。使用此 (Activity)context 获取 LayoutInflater。
适配器类没有 getActivity() 方法。
关于java - 在自定义可扩展列表适配器中扩展 View 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29992175/