作者:钻探paz_106 | 来源:互联网 | 2023-02-07 09:49
So I have a standard RecyclerView
that takes a list of posts and displays them to the user. My problem is when the user comes into the activity, I want to be able to change the focus to a particular post.
Ex. User A sees that he has a notification that of someone has liked his/her post. He/she clicks that notification, and it loads the activity of user's post, and then the focus changes to the position of the post that had bee liked.
I pass in the postID
to the activity using an intent. I then run the Recycler View
, and onBindHolder
i try to see if the post's ID matches to the postID
I sent in via intent. If it does, I now set the activity's variable postFocusPosition
to the position of that post.
Now I'm stuck on what that magic method i need to call in RecyclerView
class to actually change the focus to that item position!
Hope someone can help enlighten me on that magic line(s) of code that changes focus!
1> Ajeet Yadav..:
recyclerView.setAdapter(adapter);// set adapter on recyclerview
recyclerView.scrollToPosition(mSkipTo); //use to focus the item with index
adapter.notifyDataSetChanged();
mProgressDialog.dismiss();