直接將 char 傳給 Toast.makeText 會被視為資源 ID(int),導致 Resources$NotFoundException。需轉為 String。
char c = chars[i];
Toast.makeText(this, c, Toast.LENGTH_SHORT).show(); // 崩潰
Toast.makeText(this, String.valueOf(c), Toast.LENGTH_SHORT).show();
// 或
Toast.makeText(this, c + "", Toast.LENGTH_SHORT).show();
Toast.makeText(Context, int, int) 簽名期望資源 ID。char 隱性轉型為 int,匹配上述簽名。String 會匹配 makeText(Context, CharSequence, int)。String text = editText.getText().toString();
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
Toast.makeText(this, String.valueOf(c), Toast.LENGTH_SHORT).show();
}