expandablelistview动画

byqmnocz  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(279)

我正在尝试给动画 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);
        }

当我的孩子崩溃时,我看到了sum教程android动画:隐藏/显示菜单但没有成功。有人能告诉我怎么做吗?
和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;
        }
    });
xpszyzbs

xpszyzbs1#

必须正确重写ongroupexapnded()方法。在它内部检查其他组是否使用isexpanded()展开,如果是,则使其折叠。

相关问题