2013-06-09 3 views
0

getview 메서드에서 사용자 지정 gridview 어댑터가 있습니다 NULL 또는 빈 문자열을 확인하고 있지만 아래의 textview "null"문자열을 인쇄 할 때 조건이 작동하지 않는 것 같습니다 코드안드로이드 4.0 null을 인식하지 못합니다

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); 
     } 

답변

1

당신은 문자열 null를 확인하기 위해 "null", 및 == 대신 equals()인지 확인합니다 == 대신 .equals()를 사용해야합니다.

내가 && 경우 (ThisAttendee.AllocatedTable! = null이`으로 변경 https://stackoverflow.com/a/767379/675383

+0

하세요! ThisAttendee.AllocatedTable.toLowerCase(). (트림). 등호 ("널 (null)") &&! ThisAttendee.AllocatedTable.trim() .equals ("")) { \t \t \t \t \t ((텍스트 뷰) (gridviewitem.findViewById (R.id.tv_attendeetable)))의 setText. ("표"를 ThisAttendee.AllocatedTable +); \t \t} 이제는 텍스트 테이블 만 출력합니다. 위와 같이 제안한 결과를 시도했지만 동일한 결과가 나타납니다. –

+0

실제로 텍스트 테이블이 텍스트에서 텍스트를 하드 코딩하여 디자인 모드에서 표시되도록하는 XML에서 왔습니다.) –

관련 문제