【发布时间】:2019-02-06 08:51:35
【问题描述】:
我知道有很多帖子和问题都在讨论这个问题并解决这个问题。
但我已经尝试了所有摆在我面前的解决方案,但没有一个解决方案能解决我的问题。
所以请原谅我:)
我在使用FirebaseUi adapter 的片段中有一个recyclerView
当一个人点击一个问题并再次返回时,它有一个我想要的问题列表,recyclerView 向下滚动到该问题。所以我有意发送职位并在onActivityResult 中收到它,但它不起作用。
我用过Handler,用Timedowncounter等5秒,用过
mLayoutManager.smoothScrollToPosition(mRecyclerView,null,position);
使用过
mRecyclerView.smoothScrollToPosition(position);
使用过
scrollToPosition
甚至使用过
View recyclerView = findViewById(R.id.myView);
recyclerView.getViewTreeObserver()
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
//At this point the layout is complete and the
//dimensions of recyclerView and any child views are known.
//Remove listener after changed RecyclerView's height to prevent infinite loop
recyclerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
越来越多,没有任何事情发生
那么解决办法是什么?
谢谢你:)
我的OnActivityResult 代码
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Constants.TOPIC_INTENT_REQUEST)
{
int position = data.getExtras().getInt(Constants.POST_POSITION);
new Handler().postDelayed(() -> mLayoutManager.scrollToPositionWithOffset(position,30), 6000);
}
}
}
【问题讨论】:
-
你确定你的
onActivityResult()被叫了 -
是的,它在我的调试模式下调用
-
发布 onactivityresult 的代码。您是否调试并检查您的语句是否可访问?
-
是的,它可以到达 .. 我会更新帖子
-
你的 if 条件在调试中调用?
标签: android android-recyclerview firebaseui