简体   繁体   English

setVisibility(View.INVISIBLE)在onResume()方法中不起作用

[英]setVisibility(View.INVISIBLE) not working in onResume() method

Started an Activity B from Activity A without finishing A. if the Activity B is finished,i have written a method inside onResume() of Activity A to make an ImageView invisible. 从活动A启动活动B而不完成A。如果活动B完成,我已经在活动A的onResume()内编写了一个方法以使ImageView不可见。 But this is not working. 但这是行不通的。 Code is given below. 代码如下。

public void onResume()
{
    if(preferenceUtil.getMUSIC_ONOFF()==0) {
        try {
            player.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    giftbutton.setEnabled(true);
    giftbutton.setClickable(true);

    checkUnlockedStory();
    super.onResume();
}

  public void checkUnlockedStory()
        {
             if(preferenceUtil.getOVERALL_STARS()>=24)
            {                 
                    giftbutton.setImageResource(R.drawable.gift);
                    giftbutton_count.setVisibility(View.INVISIBLE);                  

            }
   }

make sure you have override onResume method: 确保您有重写onResume方法:

@Override
protected void OnResume()
{
super.onResume();
//Type your code here
}

尝试这个

giftbutton_count.setVisibility(View.GONE);

I think you are using wrong id ,might be missing this 我认为您使用了错误的ID,可能会遗漏此信息

giftbutton.setVisibility(View.INVISIBLE); giftbutton.setVisibility(View.INVISIBLE);

For future googlers, you might need to do yourView.clearAnimation(); 对于未来的Google员工,您可能需要执行yourView.clearAnimation(); after yourView.setVisibility(View.GONE); yourView.setVisibility(View.GONE); , since your view might already start animation once which causes extra layer still remains visible. ,因为您的视图可能已经启动了一次动画,从而导致额外的图层仍然可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM