2

每次展开一组ExpandableListView. 到目前为止,我对自定义适配器的 getChildView 进行了以下操作(基于BaseExpandableListAdapter):

public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View view,
        ViewGroup parent) {
    // Auto-generated method stub
    ExpandListChild child = (ExpandListChild) getChild(groupPosition,childPosition);
    if (view == null)
    {
        LayoutInflater inflater = 
                (LayoutInflater) m_context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view=inflater.inflate(R.layout.expandlist_child_item, null);

        AnimatorSet anim = (AnimatorSet) AnimatorInflater.loadAnimator(m_context, 
                R.animator.expand_list_animation);

        anim.setInterpolator(new OvershootInterpolator());
        anim.start();
    }

    TextView tv = (TextView) view.findViewById(R.id.tvChild);
    tv.setText(child.getName());
    tv.setTag(child.getTag());

    CheckBox cb = (CheckBox) view.findViewById(R.id.checkBox1);
    cb.setChecked(child.getState());
    return view;
}

问题是因为我只在创建新视图时应用动画,所以这只在第一次扩展组时有效。我还尝试在任何情况下应用它(不仅是 when view==null),但问题是动画是为所有扩展的孩子播放的(即使是已经扩展的其他组的孩子)。

我一直在努力让它发挥作用,但我不知道怎么做。感谢您的帮助。

4

0 回答 0