2011-03-23 8 views
2

어쩌면 어리석은 질문 일지 모르겠다.EditTextPreference

나는 EditTextPreference가 있습니다 ... 어떻게 그의 텍스트가 비어 있는지 확인 하시겠습니까? 또한 null을 확인해야

+1

내가 사용한다 같음 ...하지만 ..sorry – Jim

답변

0

작동하지 않을 것

public void onSharedPreferenceChanged(SharedPreferences sharedPreference, 
     String key) { 
    String editorText= (editTextPreference.getText()).trim(); 
    if (editorText== "") { 
     editorText.setText("Something"); 
    } 
} 

....

그것을 시도 :

if (TextUtils.isEmpty(editTextPreference.getText())) { 
    editorText.setText("Something");} 
+0

텍스트 환경 설정에 저장됩니다인가를 ==하지 ????? NULL 검사가없는 – Jim

+0

은 null 일 수 있습니다. 포인터 예외 ... – vsvydenko

관련 문제