Issue
I need to get the selected/focused item's index of the VerticalGridFragment. I found the method to set the selected item in the documentation rel="noreferrer">https://developer.android.com/reference/android/support/v17/leanback/app/VerticalGridFragment.html, i.e. setSelectedPosition(int position) which Sets the selected item position.
But I couldn't find any method in documentation which provides the selected Item or it's index.
Can someone please help me to find a work around to get the selected item of a VerticalGridFragment?
Solution
You can't get the focusing position but you can get the focusing object. Below mothod setAdapter(mAdapter);
you can write:
setOnItemViewSelectedListener(new OnItemViewSelectedListener() {
@Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
Object object = (Object) item;
//can write somethings here
}
});
Answered By - Evan Ngo
Answer Checked By - Gilberto Lyons (JavaFixing Admin)