gpt4 book ai didi

android - 动画监听器不适用于按钮单击

转载 作者:行者123 更新时间:2023-11-30 02:55:29 25 4
gpt4 key购买 nike

我正在尝试在单击按钮时隐藏/显示 TableLayout,但动画监听器不起作用,这是我正在尝试的代码

Slide_down = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide_down);
Slide_up = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide_up);

searchArea = (TableLayout) findViewById(R.id.TableLayout1);
SearchButton.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
if (check_tableView == 0) {

Slide_up.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
searchArea.setVisibility(View.VISIBLE);
}

@Override
public void onAnimationEnd(Animation animation) {
searchArea.setVisibility(View.GONE);
}

@Override
public void onAnimationRepeat(Animation animation) {

}
});


check_tableView = 1;
} else {

Slide_down.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {

searchArea.setVisibility(View.GONE);
}

@Override
public void onAnimationEnd(Animation animation) {
searchArea.setVisibility(View.VISIBLE);
}

@Override
public void onAnimationRepeat(Animation animation) {

}
});
check_tableView = 0;
}
}

});

最佳答案

//开始动画

searchArea = (TableLayout) findViewById(R.id.TableLayout1);
SearchButton.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
if (check_tableView == 0) {


searchArea.startAnimation(Slide_up);
}
});

关于android - 动画监听器不适用于按钮单击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23360168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com