안드로이드 개발 질문/답변
(글 수 45,052)
화면에 출력하고 보면 처음과 끝에 [ , ] 가 붙어있더군요..
그래서 그것을 없애려고 무수히 시도 해봤지만..
도저히 원인을 모르겠습니다..
도와주세요~
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
matches.remove("[");
matches.remove("]");
String text = matches.toString();
text.replace("[", " ");
text.replace("]", " ");
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
감사합니다.
그래서 그것을 없애려고 무수히 시도 해봤지만..
도저히 원인을 모르겠습니다..
도와주세요~
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
matches.remove("[");
matches.remove("]");
String text = matches.toString();
text.replace("[", " ");
text.replace("]", " ");
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
감사합니다.




아래는 substring으로 [ , ] 가 들어간 맨앞 글자와 맨뒷 글자빼고 가져오는 방법입니다.
String result = matches.toString();//결과값을 가져온다.
result = result.substring(1, result.length()-1); //결과값 앞뒤에 [ ] 붙는거 제거
혹시
text = text.replaceAll("[",""); //요렇게해도 안되셧는지요?