代码拉取完成,页面将自动刷新
本项目是基于开源项目 SuperRecyclerView 进行ohos化的移植和开发的,可以通过项目标签以及github地址(https://github.com/Malinskiy/SuperRecyclerView )追踪到原项目版本
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
……
}
方法2.
repositories {
maven {
url 'http://106.15.92.248:8081/repository/Releases/'
}
}
dependencies {
implementation 'com.malinskiy.ohos:superrecyclerview:1.0.0'
}
1.在布局xml中导入封装好的ListContainer控件SuperRecyclerView,设置相应宽高属性
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:orientation="vertical">
<com.malinskiy.superrecyclerview.SuperRecyclerView
ohos:id="$+id:list_superrecyclerview"
ohos:height="match_parent"
ohos:width="match_parent"/>
</DirectionalLayout>
2.设置下拉刷新功能 实现RefreshListener接口方法并将接口设置给SuperRecyclerView
@Override
public void onRefresh() {
mHandler.postTask(new Runnable() {
@Override
public void run() {
Toast.show(getContext(),"Refresh");
mAdapter.add("New stuff");
mRecycler.refreshFinish();
}
},2000);
}
@Override
public boolean enableRefresh() {
return true;
}
mRecycler.setRefreshListener(this);
注意在onRefresh方法中最后一定要回调SuperRecyclerView的refreshFinish方法 3.设置上拉加载功能 实现OnMoreListener接口方法并将接口设置给SuperRecyclerView
@Override
public void onMoreAsked(int overallItemsCount, int itemsBeforeMore, int maxLastVisiblePosition) {
mHandler.postTask(new Runnable() {
@Override
public void run() {
Toast.show(getContext(),"More");
mAdapter.add("More asked, more served");
}
},300);
}
mRecycler.setupMoreListener(this,1);
4.设置侧滑删除功能 使用BaseSwipeAdapter适配器并将其设置给SuperRecyclerView
List<String> placeHolderList = new ArrayList<>();
for (int i = 0; i < 6; i++) {
placeHolderList.add("More stuff");
}
mAdapter = new BaseSwipeAdapter(getContext(),placeHolderList);
mRecycler = (SuperRecyclerView) findComponentById(ResourceTable.Id_list_superrecyclerview);
mRecycler.setAdapter(mAdapter);
v1.0.0
-支持上拉加载更多
-支持下拉刷新
-支持侧滑子项显示删除功能
暂不支持手势侧滑直接删除子项
Copyright (c) 2016 Anton Malinskiy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Come on, don't tell me you read that.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。