介绍:万能适配器和下拉刷新下拉加载更多结合
使用方法:
###一、布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.aspsine.irecyclerview.IRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/iRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
<!--可以自定义上拉和下拉头,有默认-->
<!--app:refreshHeaderLayout="@layout/layout_irecyclerview_classic_refresh_header"-->
<!--app:loadMoreFooterLayout="@layout/layout_irecyclerview_load_more_footer"-->
app:loadMoreEnabled="true"
app:refreshEnabled="true"
tools:context=".ui.activity.MainActivity" />
<RelativeLayout
android:id="@+id/rl_root"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvTitle"
android:layout_width="match_parent"
android:layout_centerInParent="true"
android:layout_height="80dp"
android:text="数据为空哦"
android:gravity="center"
android:padding="10dp"
android:textColor="@android:color/black"
android:textSize="18sp" />
</RelativeLayout>
</RelativeLayout>
###二、java使用
######第一种情况:itemtype为一种
public class TestActivity extends FragmentActivity implements OnRefreshListener, OnLoadMoreListener {
private IRecyclerView iRecyclerView;
private CommonRecycleViewAdapter<String> adapter;
private RelativeLayout rl_root;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iRecyclerView = (IRecyclerView) findViewById(R.id.iRecyclerView);
rl_root= (RelativeLayout) findViewById(R.id.rl_root);
iRecyclerView.setLayoutManager(new LinearLayoutManager(this));
adapter=new CommonRecycleViewAdapter<String>(this, R.layout.test_item)
{
@Override
public void convert(final ViewHolderHelper holder, final String s)
{
holder.setOnClickListener(R.id.tvTitle, new View.OnClickListener() {
@Override
public void onClick(View view) {
adapter.remove(s);
Log.d("position",holder.getAdapterPosition()+"");
Log.d("positioncount",adapter.getItemCount()+"");
}
});
}
};
//adapter.openLoadAnimation(new ScaleInAnimation());
iRecyclerView.setIAdapter(adapter);
iRecyclerView.setOnRefreshListener(this);
iRecyclerView.setOnLoadMoreListener(this);
iRecyclerView.post(new Runnable() {
@Override
public void run() {
iRecyclerView.setRefreshing(true);
}
});
}
@Override
public void onRefresh() {
iRecyclerView.setLoadMoreStatus(LoadMoreFooterView.Status.GONE);
refresh();
}
@Override
public void onLoadMore(View loadMoreView) {
if (iRecyclerView.canLoadMore() && adapter.getItemCount() > 0) {
iRecyclerView.setLoadMoreStatus(LoadMoreFooterView.Status.LOADING);
loadMore();
}
}
private void refresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
iRecyclerView.setRefreshing(false);
// we can set view
ArrayList<String> strings=new ArrayList<>();
for(int i=0;i<1;i++){
strings.add(i+"个鸭子");
}
adapter.replaceAll(strings);
}
},500);
}
private void loadMore() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ArrayList<String> strings=new ArrayList<>();
for(int i=adapter.getSize();i<adapter.getSize()+10;i++){
strings.add(i+"个鸭子");
}
adapter.addAll(strings);
iRecyclerView.setLoadMoreStatus(LoadMoreFooterView.Status.GONE);
}
},500);
}
}
######第二种情况:itemtype为多种
public class TestActivity extends FragmentActivity implements OnRefreshListener, OnLoadMoreListener {
private IRecyclerView iRecyclerView;
private ChatAdapter adapter;
private ArrayList<String>strings=new ArrayList<>();
private RelativeLayout rl_root;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iRecyclerView = (IRecyclerView) findViewById(R.id.iRecyclerView);
rl_root= (RelativeLayout) findViewById(R.id.rl_root);
iRecyclerView.setLayoutManager(new LinearLayoutManager(this));
adapter=new ChatAdapter(this, strings);
//设置动画,默认渐变
adapter.openLoadAnimation(new ScaleInAnimation());
iRecyclerView.setIAdapter(adapter);
iRecyclerView.setOnRefreshListener(this);
iRecyclerView.setOnLoadMoreListener(this);
iRecyclerView.post(new Runnable() {
@Override
public void run() {
iRecyclerView.setRefreshing(true);
}
});
}
@Override
public void onRefresh() {
iRecyclerView.setLoadMoreStatus(LoadMoreFooterView.Status.GONE);
refresh();
}
@Override
public void onLoadMore(View loadMoreView) {
if (iRecyclerView.canLoadMore() && adapter.getItemCount() > 0) {
iRecyclerView.setLoadMoreStatus(LoadMoreFooterView.Status.LOADING);
loadMore();
}
}
private void refresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
iRecyclerView.setRefreshing(false);
// we can set view
ArrayList<String> strings=new ArrayList<>();
for(int i=0;i<18;i++){
strings.add(i+"个鸭子");
}
adapter.replaceAll(strings);
}
},500);
}
private void loadMore() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ArrayList<String> strings=new ArrayList<>();
for(int i=adapter.getSize();i<adapter.getSize()+10;i++){
strings.add(i+"个鸭子");
}
adapter.addAll(strings);
iRecyclerView.setLoadMoreStatus(LoadMoreFooterView.Status.GONE);
}
},500);
}
}
/**
*
*多种类型适配器
*/
public class ChatAdapter extends MultiItemCommonAdapter<String>
{
public ChatAdapter(Context context, List<String> datas)
{
super(context, datas, new MultiItemTypeSupport<String>()
{
@Override
public int getLayoutId(int position) {
if (position%2==0)
{
return R.layout.test_item;
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本资源包含一个基于Kotlin+MVP+Retrofit+RxJava+Glide+ijkplayer等架构实现的短视频资讯类app源码及项目说明。该应用采用下拉刷新和RecyclerView技术,首页展示每日精选视频推荐,并具备Banner展示功能。底部菜单采用高斯模糊效果,整体风格简约清爽。项目涵盖前端、后端、移动开发、操作系统、人工智能、物联网、数据库等多个技术领域,适合作为学习资源使用。请注意,本资源为学习资源,仅供学习和研究用途。
资源推荐
资源详情
资源评论
收起资源包目录
实现短视频资讯类app源码+项目说明.zip (504个子文件)
gradlew.bat 2KB
.gitignore 184B
.gitignore 13B
.gitignore 8B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
.gitignore 7B
config.gradle 9KB
build.gradle 4KB
build.gradle 3KB
build.gradle 3KB
build.gradle 1KB
build.gradle 887B
build.gradle 846B
build.gradle 670B
build.gradle 655B
build.gradle 613B
build.gradle 602B
build.gradle 587B
settings.gradle 305B
gradlew 5KB
Parse-1.9.4.jar 906KB
alipaySdk-20170922.jar 270KB
commons-codec-1.6.jar 227KB
gradle-wrapper.jar 53KB
libammsdk.jar 48KB
TimeUtil.java 33KB
IRecyclerView.java 29KB
ACache.java 25KB
BaseIjkVideoView.java 20KB
StandardVideoController.java 16KB
ChangeModeController.java 14KB
AdViewpagerUtil.java 14KB
ExpandTextView.java 13KB
ImgSelFragment.java 13KB
IjkVideoView.java 12KB
FormatUtil.java 12KB
OpeningStartAnimation.java 9KB
BaseActivity.java 9KB
FileUtils.java 9KB
ViewHolderHelper.java 8KB
BigImagePagerActivity.java 8KB
RotationDrawStrategy.java 8KB
ImgSelActivity.java 7KB
GestureVideoController.java 7KB
CommonRecycleViewAdapter.java 7KB
StatusBarCompat.java 7KB
Base64.java 7KB
DisplayUtil.java 7KB
WrapperAdapter.java 7KB
IjkPlayer.java 7KB
LineDrawStrategy.java 7KB
WindowUtil.java 7KB
ImageUtil.java 7KB
ResizeTextureView.java 6KB
ResizeSurfaceView.java 6KB
BaseVideoController.java 6KB
DividerGridItemDecoration.java 6KB
BaseFragment.java 6KB
SectionAdapter.java 6KB
LogUtils.java 6KB
BaseReclyerViewAdapter.java 5KB
ImgSelConfig.java 5KB
FileUtil.java 5KB
LoadingTip.java 4KB
DESBase64Util.java 4KB
AppManager.java 4KB
StorageUtil.java 4KB
NormalTitleBar.java 4KB
Compressor.java 4KB
AndroidVsIosHeaderView.java 4KB
ImageListAdapter.java 4KB
ImageLoaderUtils.java 4KB
NormalDrawStrategy.java 4KB
RxBus.java 4KB
DividerItemDecoration.java 4KB
ClassicRefreshHeaderView.java 3KB
CommonAblistViewAdapter.java 3KB
WaveView.java 3KB
RefreshHeaderLayout.java 3KB
JsonUtils.java 3KB
ToastUitl.java 3KB
PlayerConfig.java 3KB
FolderListAdapter.java 3KB
NetworkUtil.java 3KB
LoadMoreFooterView.java 3KB
RxSubscriber.java 3KB
RxCache.java 3KB
AbstractPlayer.java 3KB
RawDataSourceProvider.java 3KB
LogUtils.java 3KB
SPUtils.java 3KB
BaseAblistViewAdapter.java 3KB
RedYellowBlueDrawStrategy.java 2KB
StatusView.java 2KB
共 504 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
葡萄籽儿
- 粉丝: 578
- 资源: 1333
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- java.HttpClient与网络请求(解决方案).md
- 技术资料分享STM32固件库使用手册的中文翻译版很好的技术资料.zip
- 非常好的oracle性能优化技术内幕详解100%好用.7z
- 已停产 适用于 Android 平台的 Rrich 文本编辑器 Android富文本编辑器,暂停维护.zip
- 非常好的MySQL技术内幕详解100%好用.7z
- 技术资料分享STM32的USB详解很好的技术资料.zip
- 基于java+ssm+mysql的学生学籍管理系统任务书.doc
- vue+node+mysql实现的影视追剧管理后台系统,用于毕业设计.zip
- ProjectADC_S.zip
- 技术资料分享STM32的IAP方案很好的技术资料.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功