setvisibility:已经无法解析为变量

时间:2015-03-24 06:31:13

标签: android

我想隐藏民意调查,但设置Visibity:已经无效了。如果我为View添加参数。这是错误的说法

  

type mismatch:无法从void转换为boolean。

public void setInitialScreenDesign() {
    switch (LaunchPadConstants.loginnDetails.getLoginType()) {
    case LoginDetailsMgr.LOGINTYPE_STUDENT:
        StudentLeftFragment studentLeftFragment = (StudentLeftFragment) LaunchPadUtilities.getFragment(this, R.id.home_left_frag);
        if (studentLeftFragment != null) {
            if (studentLeftFragment.pollLinearLayout.setVisibility(GONE))
            {
                //... do something
            }
            else
            {
                //... do something else
            }
        }
        break;
    default:
        break;
    }
}

2 个答案:

答案 0 :(得分:0)

  

type mismatch:无法从void转换为boolean

因为View.setVisibility返回void而不是boolean

要检查是否使用View.getVisibility()查看View.VISIBLE(0)View.INVISIBLE(4)View.GONE(8)

答案 1 :(得分:0)

您正在设置视图的可见性,如果'条件不正确,if语句中应该有一个布尔值。但是你可以做这样的事情来完成你的工作:

if(studentLeftFragment.pollLinearLayout.getVisibility() == View.VISIBLE)
{
   studentLeftFragment.pollLinearLayout.setVisibility(GONE);
   ...
   ...
}