我已经实现了 expandablelistview 并且工作正常。现在我想在每个子列表的末尾添加“加载更多”按钮,这样如果用户单击它,它将从服务器获取更多项目。无论如何要这样做,因为在搜索了很多之后我找不到任何东西。非常感谢任何指导。
这是我的自定义适配器:
public class ExpandableListAdapterAssets extends BaseExpandableListAdapter implements Filterable {
List<View> groupViews;
ItemFilter mFilter;
boolean showCheckBox;
ArrayList<Asset> assetsToClaim;
private Context _context;
private List<AssetCategory> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<Integer, List<Asset>> _listDataChild;
private RequestBackendHelper requestBackendHelper;
public ExpandableListAdapterAssets(Context context, List<AssetCategory> listDataHeader,
HashMap<Integer, List<Asset>> listChildData, boolean b)
{
this._context = context;
this._listDataHeader = listDataHeader;
this._listDataChild = listChildData;
groupViews = new ArrayList<>();
showCheckBox = b;
assetsToClaim = new ArrayList<>();
}
@Override
public Asset getChild(int groupPosition, int childPosition)
{
return this._listDataChild.get(this._listDataHeader.get(groupPosition).getId())
.get(childPosition);
}
public List<Asset> getChildList(int groupPosition)
{
return this._listDataChild.get(this._listDataHeader.get(groupPosition).getId());
}
@Override
public long getChildId(int groupPosition, int childPosition)
{
return childPosition;
}
@Override
public View getChildView(final int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent)
{
final Asset assetChild = getChild(groupPosition, childPosition);
if (convertView == null)
{
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
TextView assetName = (TextView) convertView
.findViewById(R.id.txt_asset_name);
assetName.setText(assetChild.getName());
慕斯王
相关分类