Comments (8)
getItemCount()
in ExpandableRecyclerViewAdapter:
/**
* @return the number of group and child objects currently expanded
* @see ExpandableList#getVisibleItemCount()
*/
@Override
public int getItemCount() {
return expandableList.getVisibleItemCount();
}
it returns size of only visibleItemCount(). So if you overrides parent method, you might try to follow the logics of how it's calculated.
from expandable-recycler-view.
Hi please upload your code on StackOverflow and post a link here, I have used this library and it works perfectly fine so there must be some problem with your code.
from expandable-recycler-view.
Hi @mandybess ,
I'm also getting this same problem what @sevaktahmazyan got
FATAL EXCEPTION: mainProcess: com.thoughtbot.expandablerecyclerview.sample, PID: 2172 java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder {2dbff790 position=7 id=-1, oldPos=5, pLpos:5 scrap [attachedScrap] tmpDetached no parent}
@mandybess request you to please help us.
from expandable-recycler-view.
@rahulyadav7001 @sevaktahmazyan Same problem here :-/
from expandable-recycler-view.
@rahulyadav7001 @jamesmurphyftw please upload your code here
from expandable-recycler-view.
Activity.class:
`//...
templateFragment.setAdapter(templateGroupList, kinveyClient);
//...
TemplateFragment.class
//...
public void setAdapter(List<TemplateGroup> data, Client kinveyClient) {
progressBar.setVisibility(View.GONE);
mList.setVisibility(View.VISIBLE);
final TemplateListAdapter adapter = new TemplateListAdapter(data, this.getActivity(), kinveyClient);
mLayoutManager = new WrapContentLinearLayoutManager(getContext());
mList.setAdapter(adapter);
mList.setLayoutManager(mLayoutManager);
mList.setHasFixedSize(true);
}
//...
TemplateListAdapter.class
public class TemplateListAdapter extends ExpandableRecyclerViewAdapter<FormDataCategoryViewHolder, TemplateActionsViewHolder>{
private List<TemplateGroup> mDataset;
private Context context;
private DataStore<KCTemplateBean> templateData;
private LayoutInflater mInflater;
// Provide a suitable constructor (depends on the kind of dataset)
public TemplateListAdapter(List<TemplateGroup> myDataset, Context ctx, Client kinveyClient) {
super(myDataset);
if (ctx!=null){
context = ctx;
mInflater = LayoutInflater.from(context);
mDataset = myDataset;
templateData = DataStore.collection(AppProperties.KINVEY_COLLECTION_TEMPLATES, KCTemplateBean.class, StoreType.SYNC, kinveyClient);
}
}
@Override
public FormDataCategoryViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType){
View view = mInflater.inflate(R.layout.list_item_category, parent, false);
return new FormDataCategoryViewHolder(view);
}
@Override
public TemplateActionsViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType){
View view = mInflater.inflate(R.layout.template_actions, parent, false);
return new TemplateActionsViewHolder(view);
}
@Override
public void onBindGroupViewHolder(FormDataCategoryViewHolder holder, int flatPostition, ExpandableGroup group){
holder.setFormDataCategoryTitle(group);
}
@Override
public void onBindChildViewHolder(TemplateActionsViewHolder holder, int flatPosition, ExpandableGroup group, int childIndex){
final KCTemplateBean templateBean = (KCTemplateBean) group.getItems().get(childIndex);
holder.setTemplateActions(context, templateBean, templateData);
}
@Override
public boolean onGroupClick(int flatPosition){
return super.onGroupClick(flatPosition);
}
// Return the size of your dataset (invoked by the layout manager)
@Override
public int getItemCount() {
return mDataset.size();
}
}
TemplateActionsViewHolder.class
public class TemplateActionsViewHolder extends ChildViewHolder implements View.OnClickListener {
private Button previewButton, purchaseButton;
private KCTemplateBean templateBean;
private DataStore<KCTemplateBean> templateData;
private Context mContext;
public TemplateActionsViewHolder(View itemView){
super(itemView);
previewButton = (Button)itemView.findViewById(R.id.previewButton);
purchaseButton = (Button)itemView.findViewById(R.id.purchaseButton);
}
public void setTemplateActions(final Context context, final KCTemplateBean template, final DataStore<KCTemplateBean> templateData){
this.templateBean = template;
this.templateData = templateData;
mContext = context;
previewButton.setOnClickListener(this);
purchaseButton.setOnClickListener(this);
}
@Override
public void onClick(View v){
switch (v.getId()){
case R.id.previewButton:
//preview
} catch (Exception e) {
e.printStackTrace();
}
break;
case R.id.purchaseButton:
//purchase
break;
}
}
}
I should also mention that when any of the parent groups are expanded, the last parent disappears from the list until they are all collapsed. Each parent group has exactly one child. have another ExpandableRecyclerView that's working mostly fine, but it has a different child view holder and fixed number of parent view holders, where this one is variable.
from expandable-recycler-view.
@rajsuvariya Any advice?
from expandable-recycler-view.
Please extend a LinearLayoutManager and put an ExceptionHandler and use the CustomLinearLayout manager
public class CustomLinearLayoutManager extends LinearLayoutManager {
public LinearLayoutManagerWrapper(Context context) {
super(context);
}
public LinearLayoutManagerWrapper(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
// java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) {
}
}
}```
This will fix your issue
from expandable-recycler-view.
Related Issues (20)
- when i click on artist itemview and back again recycler view is gone HOT 1
- Add data from api
- Is it possible to put single and multiple check items in one recyclerview?
- Display the same background for Childs
- MultiTypeExpandableRecyclerViewAdapter automatically use animation in OnStart method
- How to use it with Paging HOT 1
- Tried to use preview panel provider (JavaFX WebView), but it is unavailable. Reverting to default
- There is a `toggleGroup` function which will expand a group if it is collapsed
- collapse will be called automaticly when start activity. HOT 1
- Duplicate child when expanding parents multiple times (latest release) HOT 1
- why child's default interval is big and how to setting?
- Strange Behavior on Dynamic Group Header Size
- EXPAND_STATE_MAP is private
- Migrate away from jCenter HOT 5
- Element Sorting
- When app not used for a while, expandablerecyclerview menus are empty HOT 1
- Expand and collapse smoothly HOT 1
- Allow me push access...I have updated the project to latest environment
- Error dowloading library HOT 1
- Unable to add lib in new created project (Android Studio Giraffe | 2022.3.1) HOT 2
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 expandable-recycler-view.