我正在尝试向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);
}
当孩子崩溃时,我怎么能实现,我看到了总和教程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;
}
});
答案 0 :(得分:0)
你必须正确覆盖onGroupExapnded()方法。使用isExpanded()检查其他组是否已扩展,如果它已折叠。