안드로이드 개발 질문/답변
(글 수 45,052)
버튼을 클릭할 때마다 TextView 에 문장 한줄씩 출력하게 하려고 하는데요.
아래처럼 추가를 하려고 하는데
하고보니 자꾸 원래 출력한 내용을 덮어쓰네요.
문장1 -> 첫번째로 버튼 클릭시
문장2 -> 2번째로 버튼 클릭시
문장3 -> 3번째로 버튼 클릭시
...
아래 함수를 버튼 클릭할 때마다 한번씩 호출합니다.
void DisplayHistory()
{
StringBuilder history = new StringBuilder();
if(arScore.size() != 0) {
history.append(String.format("%s,%s : %s,%s = %d:%d",
mBlueMember1.getText(), mBlueMember2.getText(),
mWhiteMember1.getText(),mWhiteMember2.getText(),
mBlueScore, mWhiteScore));
}
mHistory.setText(history.toString());
}
리스트뷰를 쓰라거나 이런말씀 말고요.
텍스트뷰에 출력하려고요.
어디가 문제가 있는지 도움 부탁드립니다.




mHistory에 덮어쓰시고 싶단 말씀이신거죠?
setText(str)을 하게 되면 str값만 보여주므로
기존 내용에 덧붙으실리면 mHistory.setText(mHistory.getText().toString() + "\n" +history.toString())하시거나.
history에서 기존 textview의 내용을 먼저 추가해놓으시고 다음 문자열을 붙이시면 될것 같네요