setVisibility 不起作用
setVisibility not working
如果登录用户是捐助者,我会尝试隐藏一个按钮。我有这样的代码。
String typ = user.get("type").toString();
Log.d("before checking type", typ);
if (typ == "Donor"){
ne.setVisibility(View.GONE);
//ne.setEnabled(false);
}
在日志中,我得到了结果 Donor
,所以我知道对数据库的调用正在运行。但是我需要隐藏的按钮并没有隐藏。有人知道为什么吗?
更改为:
if (typ.equals("Donor"))
如果登录用户是捐助者,我会尝试隐藏一个按钮。我有这样的代码。
String typ = user.get("type").toString();
Log.d("before checking type", typ);
if (typ == "Donor"){
ne.setVisibility(View.GONE);
//ne.setEnabled(false);
}
在日志中,我得到了结果 Donor
,所以我知道对数据库的调用正在运行。但是我需要隐藏的按钮并没有隐藏。有人知道为什么吗?
更改为:
if (typ.equals("Donor"))