나는 목록 항목이 있습니다. 각 항목은 Textview를 확장하여 사용자 정의 된 항목을 만듭니다. super.setText(Charsequence text, BufferType type)
을 호출하기 전에이 클래스에서 텍스트 처리를 수행하는 setText(CharSequence text, BufferType type)
메서드를 재정의합니다.
그러나 text.toString()
메서드를 호출하면 빈 문자열이 반환됩니다.CharSequnce variable.toString() 빈을 반환합니다.
같은 문제가 있습니까? 물론 유니 코드 텍스트를 사용합니다 (예 : \u0661\u6662\u663
). 목록보기에 유니 코드 날짜를 표시하는 데 문제가 없습니다.
이 내 재정 및 처리 방법 : process(String text)
에서
@Override
public void setText(CharSequence text, BufferType type) {
// TODO Auto-generated method stub
process(text.toString());
super.setText(text, type);
}
private void process(String guess) {
StringBuffer correct = new StringBuffer(GameForm.getCorrectNumber());
int s = guess.length();
if (s!=correct.length())
throw new InputMismatchException("Lenght of correct and guess number is different");
acceptCount = 0;
warningCount = 0;
for (int i = 0; i < s; i++) {
if (guess.charAt(i) == correct.charAt(i)) {
acceptCount++;
} else if (correct.indexOf(guess.charAt(i) + "") != -1) {
warningCount++;
}
}
}
s
가 비어 있습니다!
오버라이드 방식을 제공하십시오. 빈 문자열이되도록 대부분 텍스트를 처리해야합니다. 앱 디버깅을 시도하고 왜 변경되는지 확인합니다. –
질문이 업데이트됩니다. 그것을보십시오. –