[英]String comparison not working (android)
My string comparison is not working. 我的字符串比较不起作用。 I do not know why. 我不知道为什么。 It returns that it is always equal even when the two strings are not the same 即使两个字符串不相同,它也会返回它总是相等的
here is the code Im using 这是我使用的代码
if(videoFile.equals(LangSelect.INSTRUCTION_01));
{
Log.i("InstructionVideo", "video and instruction are equal\n"+ videoFile + "\n" + LangSelect.INSTRUCTION_01);
//hideBackButton();
}
The videoFile is intro_x.mp4 where x changes to number from 0 to 4 while INSTRUCTION_01 is into_0.mp4 videoFile是intro_x.mp4,其中x从0变为4,而INSTRUCTION_01是into_0.mp4
the part of my onCreate that does sets videoFile variable 我的onCreate的一部分确实设置了videoFile变量
//get which video file to play
videoFile = getIntent().getExtras().getString("PlayVideo");
Log.i("InstructionVideo", "videoFile name: " +videoFile);
Here is the LogCat of that portion 这是该部分的LogCat
05-15 14:59:57.078: I/InstructionVideo(2952): videoFile name: intro_0.mp4
05-15 14:59:57.085: I/InstructionVideo(2952): video and instruction are equal
05-15 14:59:57.085: I/InstructionVideo(2952): intro_0.mp4
05-15 14:59:57.085: I/InstructionVideo(2952): intro_0.mp4
05-15 14:59:57.124: I/surfaceCreated(2952): created
05-15 14:59:58.324: I/LangSelect(2952): 7
05-15 14:59:58.390: I/InstructionVideo(2952): videoFile name: intro_1.mp4
05-15 14:59:58.390: I/InstructionVideo(2952): video and instruction are equal
05-15 14:59:58.390: I/InstructionVideo(2952): intro_1.mp4
05-15 14:59:58.390: I/InstructionVideo(2952): intro_0.mp4
05-15 14:59:58.433: I/surfaceCreated(2952): created
05-15 14:59:58.484: I/SurfaceDestroyed(2952): destroyed
05-15 15:00:07.382: I/LangSelect(2952): 7
05-15 15:00:07.445: I/InstructionVideo(2952): videoFile name: intro_2.mp4
05-15 15:00:07.449: I/InstructionVideo(2952): video and instruction are equal
05-15 15:00:07.449: I/InstructionVideo(2952): intro_2.mp4
05-15 15:00:07.449: I/InstructionVideo(2952): intro_0.mp4
05-15 15:00:07.488: I/surfaceCreated(2952): created
05-15 15:00:07.539: I/SurfaceDestroyed(2952): destroyed
05-15 15:00:23.535: I/LangSelect(2952): 7
05-15 15:00:23.597: I/InstructionVideo(2952): videoFile name: intro_3.mp4
05-15 15:00:23.597: I/InstructionVideo(2952): video and instruction are equal
05-15 15:00:23.597: I/InstructionVideo(2952): intro_3.mp4
05-15 15:00:23.597: I/InstructionVideo(2952): intro_0.mp4
05-15 15:00:23.632: I/surfaceCreated(2952): created
05-15 15:00:23.687: I/SurfaceDestroyed(2952): destroyed
05-15 15:00:38.843: I/LangSelect(2952): 7
05-15 15:00:38.902: I/InstructionVideo(2952): videoFile name: intro_4.mp4
05-15 15:00:38.906: I/InstructionVideo(2952): video and instruction are equal
05-15 15:00:38.906: I/InstructionVideo(2952): intro_4.mp4
05-15 15:00:38.906: I/InstructionVideo(2952): intro_0.mp4
05-15 15:00:38.941: I/surfaceCreated(2952): created
05-15 15:00:38.992: I/SurfaceDestroyed(2952): destroyed
05-15 15:01:13.242: I/LangSelect(2952): 7
05-15 15:01:13.296: I/SurfaceDestroyed(2952): destroyed
It shows that even as i compare them they return true but are not 它表明,即使我比较它们,它们返回真实但不是
There's a ;
有一个;
at the end of the "if" line, which terminates the "if" statement, therefore the following block is always executed. 在“if”行的末尾,它终止“if”语句,因此始终执行以下块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.