Closed 54binge closed 8 years ago
Hi @54binge, you don't have to call showAllHeaders()
because that method is already called in setDisplayHeadersAtStartUp()
.
Also for the HeaderViewHolder, you need to pass true to the super constructor, to avoid some crashing issues when you will scroll.
Hi @davideas ,thanks for your reply. In fact, the application crashed immediately when setDisplayHeadersAtStartUp() is called,there is nothing to do with the scrolling. And I can't find where to pass "true" in the HeaderViewHolder constructor. looking forward to your next reply!
@54binge, indeed scrolling is a different thing, but if you don't find the new parameter means that you are using an old version, please use beta7, and you actually need it. (I've updated a little the Wiki for beta7).
Regarding the main problem, I think it's the double call, but I need to check better, in the meantime, please remove showAllHeaders()
and try it out.
Another important thing, you have to provide a copy of dataList. At the moment that is necessary.
@54binge, I've tried your code, I removed the creation of dataList
because I don't have the objects. But I used my own list and everything works fine, just the header is duplicated because duplicated is the call...
Can you please enable logs and paste them here, and also can you try to run it debug mode?
@davideas it works fine use handler,i need research it more. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test2);
RecyclerView rcv = (RecyclerView) findViewById(R.id.rcv);
rcv.setLayoutManager(new StaggeredGridLayoutManager(4, StaggeredGridLayoutManager.VERTICAL));
getLocalData();
final FlexibleAdapter adapter = new FlexibleAdapter(dataList);
rcv.setAdapter(adapter);
rcv.addItemDecoration(new DividerItemDecoration(this, R.drawable.horizontal_line));
baseHandler.post(new Runnable() {
@Override
public void run() {
adapter.showAllHeaders();
}
});
adapter.enableStickyHeaders();
}
Well, it is a workaround, it would be interesting to see your logs, maybe there's a problem somewhere else.
@54binge, ok I've seen the logs and deleted the message, not useful. I need that you enable the logs of the Adapter and send that to me. Also put some logs in the various methods of your Activity so I can know in which point the execution is.
And please apply all the instructions that I told you previously. Thanks.
@davideas when i see the logs,i also think it not useful,even if i call FlexibleAdapter.enableLogs(true); just now, i put the method setAdapter() after method adapter.setDisplayHeadersAtStartUp(true), all become normal and works very well. thank you for these days!
Cool, so the problem is the order of the set?
I wonder why the demo App doesn't crash too, can you put here the logs of when it crashes?
Because I'm rewriting the Wiki pages just now and I need to be sure that the call setDisplayHeadersAtStartUp()
can be after or must be before setting the Adapter to the RV.
Thanks.
I pasted all logs when it crashed,when it became normal,i tried the order of method setDisplayHeadersAtStartUp(true)
,in fact,it is not the reason,i think it is better to call it after setAdapter()
,maybe it is the time to restart android studio or reboot my computer :)
I understood that could be something related with the setContentView and view hierarchy even before the Adapter since you don't see any logs from it when you enableLogs().
hi@davideas ,so sorry to disturb you,i try to make a sticky grid header,it can show items well when without adapter.setDisplayHeadersAtStartUp(true) or adapter.showAllHeaders(), but if i set one, it crashed, Caused by: java.lang.StackOverflowError: stack size 8MB at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:6335)
here is my code, wish you'r help
public class TestActivity2 extends BaseActivity { private static final String TAG = "TestActivity2";
}