I want my app to auto-scroll at particularGroup in ExpandableList when a user selects a particular group name from RecyclerView. I am using the Interface to handle the click from RecyclerView
here is my mainActivity code:
@Override
public void onItemClick(int position) {
menuListForRestaurant.setVisibility(View.GONE);
if (!menuOpenChecker){
menuOpenChecker=true;
}else{
menuOpenChecker=false;
}
//The above code gets execute except for the below one
listView.smoothScrollToPosition(position);// this line is not executing
}
@SuppressLint("ClickableViewAccessibility")
private void ListViewAdapter(final HashMap<String, ArrayList<ProductList>> objectMap, final ArrayList<String> headerList) {
listViewAdapter= new RestaurantItemListView(RestaurantDetail.this.getApplicationContext(), objectMap,headerList);
listView.setAdapter(listViewAdapter);
listViewAdapter.notifyDataSetChanged();
}
private void RecyclerMenuView(ArrayList<String> headerList){
menuItemRecyclerView.setLayoutManager(new LinearLayoutManager(this));
menuItemRecyclerView.getRecycledViewPool().clear();
menuAdapterRecyclerView= new RestaurantMenuRecyclerView(headerList, this.getApplicationContext());
menuItemRecyclerView.setItemAnimator(new DefaultItemAnimator());
menuItemRecyclerView.setAdapter(menuAdapterRecyclerView);
menuAdapterRecyclerView.notifyDataSetChanged();
menuAdapterRecyclerView.setOnClick(RestaurantDetail.this);
}
Its like the line which I have mentioned as not working because it doesn't get updated at the ExpandableListView
Thank you in Advance please anyone??
I have Finally resolved issue by using simeple code below:
//AutoScroll for menu
int t = 0,j, e=0, l=0;
for (int n=0; n<=position;n++){
e= e +objectMap.get(textHeaderlist.get(n)).size();
l= l+450;
}
t=position+1;
j= 200+e+t+l;
scrollView.scrollTo(5, j);
which finally resolve my issue.
Either way, thank you!