【问题标题】:ExpandableListView Animation while closing expanded list关闭展开列表时的 ExpandableListView 动画
【发布时间】:2014-03-11 10:53:37
【问题描述】:

我正在尝试为ExpandableListView 提供动画。当使用以下代码单击组时,我确实设法为扩展列表提供动画

               public View getChildView(final int groupPosition,
            final int childPosition, boolean isLastChild, View convertView,
            ViewGroup parent) {

        if (convertView == null) {
            vv = (RelativeLayout) getLayoutInflater().inflate(
                    R.layout.homescreen_submenu, null);
        } else {
            vv = (RelativeLayout) convertView;
        }

        animation = AnimationUtils.loadAnimation(getApplicationContext(),
                R.anim.anim_pushin);
        vv.startAnimation(animation);
        }

child-collapse怎么实现,看了sum教程Android Animation: Hide/Show Menu没成功。谁能告诉我怎么做?

和 2)当我在组展开时滚动,然后如果我点击第 2 组,则 2 组标题会出现在屏幕之外,我可以看到它的子菜单。

我尝试了选择位置,但没有成功。

编辑:- 我也看到了这个http://upadhyayjiteshandroid.blogspot.in/2013/03/android-exapandlistview-animation.html,但我希望在单击组时显示列表

Edit2:我已经添加了这个代码,但是在这个唯一的最后一个孩子是动画的

    mainmenu.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {

        public boolean onGroupClick(final ExpandableListView parent,
                View v, final int groupPosition, long id) {
            if (groupPosition == 2) {
                Toast.makeText(Homescreen.this, "Group 2 clicked",
                        Toast.LENGTH_LONG).show();
                return true;
            }
            if (groupPosition == 3) {
                Intent nextscreen = new Intent(getApplicationContext(),
                        reminder.class);
                startActivity(nextscreen);
                finish();
                return true;
            }

            if (groupPosition == 5) {
                Toast.makeText(Homescreen.this, "Group 3 clicked",
                        Toast.LENGTH_LONG).show();
                return true;
            } else

            if (mainmenu.isGroupExpanded(groupPosition)) {

                vv.startAnimation(animationc);
                animationc.setAnimationListener(new AnimationListener() {

                    @Override
                    public void onAnimationStart(Animation animation) {
                        // TODO Auto-generated method stub
                        vv.setBackgroundColor(getResources().getColor(
                                R.color.white_trs));
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                        // TODO Auto-generated method stub

                    }

                    @Override
                    public void onAnimationEnd(Animation arg0) {
                        // TODO Auto-generated method stub
                        mainmenu.collapseGroup(groupPosition);

                    }
                });

                return true;
            }
            return false;
        }
    });

【问题讨论】:

    标签: java android animation expandablelistview


    【解决方案1】:

    您必须正确覆盖 onGroupExapnded() 方法。检查其中是否使用 isExpanded() 扩展了其他组,如果它使其折叠。

    【讨论】:

    • 但是如何为 public View getChildView 设置动画?我试过如果 grp.isExpanded(){ list.startanimation} 但在这个完整列表中获得动画效果我只希望子列表被动画
    • 子项中你想要哪种类型的动画???你能发布你的孩子的xml文件吗?
    • 我无法设置子列表折叠时的动画,任何动画都可以
    猜你喜欢
    • 1970-01-01
    • 2012-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-24
    相关资源
    最近更新 更多