当用户从RecyclerView中选择特定组名时,我希望我的应用在ExpandableList中的特定组处自动滚动。我正在使用界面处理来自RecyclerView的点击
下面是我主要活动代码:
@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);
}
这就像我提到的不工作的行,因为它没有在ExpandableListView中更新
提前谢谢你,请任何人??
3条答案
按热度按时间w8rqjzmb1#
我终于解决了这个问题,通过使用下面的简单代码:
终于解决了我问题
不管怎样,谢谢你!
ssm49v7z2#
由于您使用的是NonScrollExpandableListView,因此ExpandableListView不会滚动。这里我展示了3种可能的解决方案:
2.带标题的可展开列表视图(NoScrollView):开始一个新的项目并尝试这个示例,验证它是否符合您的要求。在这里我使用了Spinner而不是RecyclerView。
MainActivity.java:
CustomBaseExpandableListAdapter.java:
活动_主.xml:
header.xml:
1.使用ViewPager作为子视图(ExpandableListView with ViewPager combination as its child)的可扩展列表视图,使用HorizontalRecyclerView作为子视图的可扩展列表视图(子视图为HorizontalScroll View的可扩展列表视图):使用其中一种方法并设置ExpandableListView的
OnGroupExpandListener
只展开一个组,那么我认为当前的RecyclerView在没有必要。qxsslcnc3#
'pos'滚动到位置值