Comments (12)
我马上解决下!
from lrecyclerview.
请贴一下你的布局文件吧!
from lrecyclerview.
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<com.github.jdsjlzx.recyclerview.LuRecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.support.v4.widget.SwipeRefreshLayout>
from lrecyclerview.
是设置item点击事件报错吗?贴一下出错log!
from lrecyclerview.
Process: com.laima365.laimaboss, PID: 31060
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.jdsjlzx.recyclerview.LuRecyclerViewAdapter.setScrollState(int)' on a null object reference
at com.github.jdsjlzx.recyclerview.LuRecyclerView.onScrollStateChanged(LuRecyclerView.java:276)
at android.support.v7.widget.RecyclerView.dispatchOnScrollStateChanged(RecyclerView.java:4334)
at android.support.v7.widget.RecyclerView.setScrollState(RecyclerView.java:1290)
at android.support.v7.widget.RecyclerView$ViewFlinger.fling(RecyclerView.java:4517)
at android.support.v7.widget.RecyclerView.fling(RecyclerView.java:1945)
at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:2725)
at android.view.View.dispatchTouchEvent(View.java:9427)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2660)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2304)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666
from lrecyclerview.
引用 compile 'com.github.jdsjlzx:LRecyclerView:1.2.1' 试试,如还有问题请提出详细log。
from lrecyclerview.
感谢你对本框架的支持和理解,有问题及时提出,我会尽快解决…
from lrecyclerview.
compile 'com.github.jdsjlzx:LRecyclerView:1.2.1'
多次点击还有问题
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.jdsjlzx.recyclerview.LuRecyclerViewAdapter.setScrollState(int)' on a null object reference
at com.github.jdsjlzx.recyclerview.LuRecyclerView.onScrollStateChanged(LuRecyclerView.java:276)
at android.support.v7.widget.RecyclerView.dispatchOnScrollStateChanged(RecyclerView.java:4334)
at android.support.v7.widget.RecyclerView.setScrollState(RecyclerView.java:1290)
at android.support.v7.widget.RecyclerView$ViewFlinger.fling(RecyclerView.java:4517)
at android.support.v7.widget.RecyclerView.fling(RecyclerView.java:1945)
at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:2725)
at android.view.View.dispatchTouchEvent(View.java:9427)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2660)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2304)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666)
from lrecyclerview.
多次点击这个你代码是怎么写的,贴出来看看
from lrecyclerview.
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.jdsjlzx.recyclerview.LuRecyclerView;
import com.github.jdsjlzx.recyclerview.LuRecyclerViewAdapter;
import com.github.jdsjlzx.util.LuRecyclerViewStateUtils;
import com.github.jdsjlzx.view.LoadingFooter;
import com.laima365.laimaboss.R;
import com.laima365.laimaboss.event.StartBrotherEvent;
import com.laima365.laimaboss.model.BaseModel;
import com.laima365.laimaboss.model.IntegralUserList;
import com.laima365.laimaboss.model.JBModel;
import com.laima365.laimaboss.model.RechargeUserList;
import com.laima365.laimaboss.nohttp.CallServer;
import com.laima365.laimaboss.nohttp.FastJsonRequest;
import com.laima365.laimaboss.nohttp.HttpListener;
import com.laima365.laimaboss.ui.activity.BaseAppCompatActivity;
import com.laima365.laimaboss.ui.adapter.RecycleHolder;
import com.laima365.laimaboss.ui.adapter.RecyclerAdapter;
import com.laima365.laimaboss.ui.view.RecycleViewDivider;
import com.laima365.laimaboss.utils.AppUtil;
import com.laima365.laimaboss.utils.Constants;
import com.laima365.laimaboss.utils.GlideImgManager;
import com.laima365.laimaboss.utils.ToastUtils;
import com.yolanda.nohttp.RequestMethod;
import com.yolanda.nohttp.rest.Request;
import com.yolanda.nohttp.rest.Response;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
_/
public class JfFragment extends BaseFragment implements HttpListener,SwipeRefreshLayout.OnRefreshListener {
@BindView(R.id.jf_list)
LuRecyclerView mRecyclerView;
@BindView(R.id.swipe_refresh_jflayout)
SwipeRefreshLayout mSwipeRefreshLayout;
/_每一页展示多少条数据/
private static final int REQUEST_COUNT = 10;
private int pageNum=1;
private RecyclerAdapter recyclerAdapter;
private List<IntegralUserList.DataBean.UserShopScoreListBean> jflist;
private LuRecyclerViewAdapter mLRecyclerViewAdapter;
public static JfFragment newInstance() {
Bundle args = new Bundle();
JfFragment fragment = new JfFragment();
fragment.setArguments(args);
return fragment;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.jffragment, container, false);
ButterKnife.bind(this, view);
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initData();
initEvent();
addUserShopRemark();
}
private void initData() {
//设置刷新时动画的颜色,可以设置4个
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setProgressViewOffset(false, 0, AppUtil.dip2px(getActivity(),48));
mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light);
mSwipeRefreshLayout.setOnRefreshListener(this);
}
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mRecyclerView.addItemDecoration(new RecycleViewDivider(
getActivity(), LinearLayoutManager.HORIZONTAL, 2, ContextCompat.getColor(getActivity(), R.color.line)));
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mRecyclerView.addItemDecoration(new RecycleViewDivider(
getActivity(), LinearLayoutManager.HORIZONTAL, 2, ContextCompat.getColor(getActivity(), R.color.line)));
}
private void initEvent() {
mRecyclerView.setLScrollListener(new LuRecyclerView.LScrollListener() {
@Override
public void onScrollUp() {
}
@Override
public void onScrollDown() {
}
@Override
public void onBottom() {
flag=MORE;
LoadingFooter.State state = LuRecyclerViewStateUtils.getFooterViewState(mRecyclerView);
if(state == LoadingFooter.State.Loading) {
return;
}
// if (pageNum < TOTAL_COUNTER) {
pageNum++;
LuRecyclerViewStateUtils.setFooterViewState(getActivity(), mRecyclerView, REQUEST_COUNT, LoadingFooter.State.Loading, null);
addUserShopRemark();
// } else {
//the end
// LuRecyclerViewStateUtils.setFooterViewState(getActivity(), mRecyclerView, REQUEST_COUNT, LoadingFooter.State.TheEnd, null);
// }
}
@OverRide
public void onScrolled(int distanceX, int distanceY) {
}
@Override
public void onScrollStateChanged(int state) {
}
});
}
/**
* 商家对用户印象标签
*/
private void addUserShopRemark() {
Request<JSONObject> request = new FastJsonRequest(Constants.API.INTEGRALUSERLIST_SHOPMANAGER, RequestMethod.POST);
request.add("pageNum",pageNum);
CallServer.getRequestInstance().add((BaseAppCompatActivity) getActivity(), INTEGRALUSERLIST, request, this, false, false);
}
private void showList(List<IntegralUserList.DataBean.UserShopScoreListBean> tlist) {
if (recyclerAdapter == null) {
jflist=tlist;
recyclerAdapter = new RecyclerAdapter<IntegralUserList.DataBean.UserShopScoreListBean>(getActivity(),jflist, R.layout.jf_item) {
@Override
public void convert(RecycleHolder holder,final IntegralUserList.DataBean.UserShopScoreListBean data, int position) {
GlideImgManager.loadImage(getActivity(),data.getIcon(),(ImageView) holder.findView(R.id.image_dpyg));
holder.setText(R.id.name,data.getName());
holder.setText(R.id.num,data.getScore());
holder.findView(R.id.relay_jf).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EventBus.getDefault().post(new StartBrotherEvent(SjDetailFragment.newInstance(data.getUserId()+"",2)));//2:积分
}
});
}
};
mLRecyclerViewAdapter = new LuRecyclerViewAdapter(recyclerAdapter);
mRecyclerView.setAdapter(mLRecyclerViewAdapter);
}else{
if (jflist == null || jflist.size() == 0) {
jflist = tlist;
} else {
for (int i = 0; i < tlist.size(); i++) {
jflist.add(tlist.get(i));
}
}
recyclerAdapter.onDateChange(jflist);
}
}
@Override
public void onSucceed(int what, Response<JSONObject> response) {
if(what==INTEGRALUSERLIST){
BaseModel info = JSON.parseObject(response.get().toString(), BaseModel.class);
if (info.getState() == Constants.SUCCEED) {
IntegralUserList reinfo = JSON.parseObject(response.get().toString(), IntegralUserList.class);
if(flag==REFRESH){
mSwipeRefreshLayout.setRefreshing(false);
}else{
LuRecyclerViewStateUtils.setFooterViewState(mRecyclerView, LoadingFooter.State.Normal);
mSwipeRefreshLayout.setRefreshing(false);
}
if(reinfo.getData().getUserShopScoreList().size()==0){
ToastUtils.show("数据加载完!");
LuRecyclerViewStateUtils.setFooterViewState(getActivity(), mRecyclerView, REQUEST_COUNT, LoadingFooter.State.TheEnd, null);
}else{
showList(reinfo.getData().getUserShopScoreList());
}
} else {
JBModel jbinfo = JSON.parseObject(response.get().toString(), JBModel.class);
ToastUtils.show(jbinfo.getData());
}
}
}
@Override
public void onFailed(int what, Response<JSONObject> response) {
((BaseAppCompatActivity) getActivity()).showMessageDialog(R.string.request_failed, response.getException().getMessage());
}
@Override
public void onRefresh() {
flag=REFRESH;
pageNum =1;
mSwipeRefreshLayout.setRefreshing(true);
addUserShopRemark();
}
}
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_jflayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<com.github.jdsjlzx.recyclerview.LuRecyclerView
android:id="@+id/jf_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.support.v4.widget.SwipeRefreshLayout>
from lrecyclerview.
你加我QQ:573842281,我远程给你看看吧!
from lrecyclerview.
compile 'com.github.jdsjlzx:LRecyclerView:1.2.2' 新版本解决问题!
from lrecyclerview.
Related Issues (20)
- LRecyclerView有线性管理器和瀑布流管理器的切换功能么
- 每次使用下拉刷新后,接下来上拉加载的View都不能出现 HOT 1
- 请问如何替换头部?
- SectionAnimalActivity有问
- 不满一屏不能上拉加载更多,Demo也不行
- refreshComplete奔溃
- 上拉加载更多加载完成FooterView不能自动隐藏 HOT 2
- android X 下适配问题
- 强制刷新问题 HOT 1
- 不支持局部刷新
- 关于setNomore()方法 HOT 1
- 关于setNoMore
- demo中的滑动冲突问题 为啥直接忽略了?
- 1.5.4.3设置paddingTop后无法下拉刷新
- 怎么局部刷新
- 能同时支持左右滑动么,Demo里面怎么只能选一种滑动?
- 混淆后偶尔会下拉刷新失效
- 不显示上拉加载更多的footview HOT 2
- 远程依赖最新版本(1.5.3)与从该库下载后导入本地的源代码不一致
- ExpandableActivity中显示错乱
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lrecyclerview.