Android:无法设置自定义RecyclerView项的子文本视图的动画()

Android:无法设置自定义RecyclerView项的子文本视图的动画(),android,animation,android-recyclerview,android-viewholder,Android,Animation,Android Recyclerview,Android Viewholder,我有一个自定义的折叠单元格布局,用于回收视图中的每个项目。我在折叠单元格中有一个子textView,如果某个条件是真的,我想对其设置动画,如下所示: @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { // if this item is unfolded only bind the unfolded child views if (u

我有一个自定义的
折叠单元格
布局,用于
回收视图中的每个项目
。我在折叠单元格中有一个子
textView
,如果某个条件是真的,我想对其设置动画,如下所示:

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        // if this item is unfolded only bind the unfolded child views
        if (unfoldedIndexes.contains(position)) {
            holder.cell.unfold(true);
            bindUnfoldedState(holder, holder.getLayoutPosition());
        }else{
            // else bind the child views visibel when folded
            holder.cell.fold(true);
            bindFoldedState(holder, holder.getLayoutPosition());
        }
    }

    public void bindUnfoldedState(ViewHolder holder, int position){

        // classes holds all the elements in the recyclerView
        myClass class = classes.get(position);

            if(classes.isbuttonEnabled()){
                Log.i("BIND","entered");

                // after entering here, animation does not happen the first time
                holder.priceText.animate().alpha(1.0f).setDuration(500);
                holder.priceText.animate().translationY(-38).setDuration(1000);
                holder.buttonText.animate().translationY(38).setDuration(1000);
            }else {
               // reset animation if button is false

               holder.priceText.animate().alpha(0.0f).setDuration(500);
               holder.priceText.animate().translationY(0).setDuration(500);
               holder.buttonText.animate().translationY(0).setDuration(500);
            }

            // setting custom button handler here . . .      
    }
我在
textPrice
视图中显示的片段中进行一些计算后,调用
onItemChanged()
。因此,onItemChanged()将调用
onBindViewHolder
,并在
isButtonEnabled
为true时执行动画,我使用我的
setButtonEnabled(true)
方法确保这一点,如下所示:

 // ok is a button in this dialog fragment 
 ok.setOnClickListener(new View.OnClickListener(){

    @Override
    public void onClick(View view) {

        myclass.setButtonEnabled(true);
        // this is them setting the text to textPrice
        myclass.setPrice(55);
        adapter.notifyItemChanged(Position);
    }
}
上面的代码片段是出现在
recyclerview
上方的另一个片段-对话框片段的一部分

问题是正在调用onBindViewHolder,并且正在输入动画条件,但动画没有出现。再次按下“ok”(确定)按钮-因此再次调用
onItemChanged()
-动画就会发生

为什么它不是第一次发生

当我最初尝试使用
listView
时,它按预期工作,因此它可能与布局无关,但与recyclerView/viewHolder/adapter有关