我正在創建一個設置活動,無論用戶是否能夠激活/取消激活通知。現在我想顯示/隱藏點擊切換按鈕上的某些選項。我可以隱藏視圖但不知道如何再次顯示?在這裏,我正在粘貼我的切換代碼:如何顯示/隱藏視圖/佈局在開關點擊android?
notify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b)
{
notifyMail.animate()
.translationY(0)
.alpha(0.0f)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
notifyMail.setVisibility(View.GONE);
}
});
notifyPhone.animate()
.translationY(0)
.alpha(0.0f)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
notifyPhone.setVisibility(View.GONE);
}
});
notifyHitcher.animate()
.translationY(0)
.alpha(0.0f)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
notifyHitcher.setVisibility(View.GONE);
}
});
notifyDriver.animate()
.translationY(0)
.alpha(0.0f)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
notifyDriver.setVisibility(View.GONE);
}
});
}
else
{
notifyMail.animate().translationY(0);
}
}
});
其餘部分將在其他部分完成{}。在此先感謝
非常感謝你,你的解決方案工作:) – ManishNegi