Java OnChildViewWholderSelectedListener在使用setSelectedPositionSmooth在HorizontalGridView中完成动画之前被调用
我在Java OnChildViewWholderSelectedListener在使用setSelectedPositionSmooth在HorizontalGridView中完成动画之前被调用,java,android,leanback,Java,Android,Leanback,我在android.support.v17.leanback.widget包中使用HorizontalGridView。问题是调用onChildViewWholderSelectedListener的太早 horizontalGrid.setSelectedPosition(position); horizontalGrid.setOnChildViewHolderSelectedListener(new OnChildViewHolderSelectedListener() {
android.support.v17.leanback.widget
包中使用HorizontalGridView
。问题是调用onChildViewWholderSelectedListener的太早
horizontalGrid.setSelectedPosition(position);
horizontalGrid.setOnChildViewHolderSelectedListener(new OnChildViewHolderSelectedListener() {
@Override
public void onChildViewHolderSelected(RecyclerView parent, RecyclerView.ViewHolder child, int position, int subposition) {
super.onChildViewHolderSelected(parent, child, position, subposition);
//the animation isn't complete
//horizontalGrid.getLayoutManager().isSmoothScrolling() is true;
}
});
我知道的唯一选择是将TimerTask
与Timer
一起使用,并检查horizontalGrid.getLayoutManager().isSmoothScrolling()
是否为false。另一个不太可靠的解决方案是将处理程序
与postDelayed
方法结合使用。就我而言,这两种方式都很丑陋。
我还没有找到任何内置的方法。我错过什么了吗?还有更优雅的吗?我也有同样的问题。我试图查找选定子对象的X坐标,但该值错误,因为此回调在动画更改视图位置之前出现。我试过在ChildviewHolder Selected和Positioned上使用,但没有帮助-它不是一直被调用,而且X坐标仍然是错误的。