0

我在 getview 方法中有自定义 gridview 适配器我正在检查 String 是否为 NULL 或 Empty,但条件似乎不起作用,因为它将字符串“null”打印到下面的 textview 是代码

if(!ThisAttendee.AllocatedTable.equals(null) && ThisAttendee.AllocatedTable.toLowerCase().trim() != "null" && !ThisAttendee.AllocatedTable.trim().isEmpty())
        {
            ((TextView)(gridviewitem.findViewById(R.id.tv_attendeetable))).setText("Table: "+ThisAttendee.AllocatedTable);
        }
4

1 回答 1

1

您需要使用.equals()而不是==检查字符串是否为"null",而==不是equals()检查null.

https://stackoverflow.com/a/767379/675383

于 2013-06-09T12:55:54.240 回答