介绍:万能适配器和下拉刷新下拉加载更多结合
使用方法:
###一、布局文件
<?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;
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 3、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 基于Kotlin+MVP+Retrofit+RxJava+Glide+ijkplayer 等架构实现短视频资讯类app源码+项目说明.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于Kotlin+MVP+Retrofit+RxJava+Glide等架构实现短视频资讯类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
资源评论
土豆片片
- 粉丝: 1852
- 资源: 5869
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功