簡體   English   中英

字符串比較不起作用(android)

[英]String comparison not working (android)

我的字符串比較不起作用。 我不知道為什么。 即使兩個字符串不相同,它也會返回它總是相等的

這是我使用的代碼

if(videoFile.equals(LangSelect.INSTRUCTION_01));
    {
        Log.i("InstructionVideo", "video and instruction are equal\n"+ videoFile + "\n" + LangSelect.INSTRUCTION_01);

        //hideBackButton();
    }

videoFile是intro_x.mp4,其中x從0變為4,而INSTRUCTION_01是into_0.mp4

我的onCreate的一部分確實設置了videoFile變量

    //get which video file to play
    videoFile = getIntent().getExtras().getString("PlayVideo");

    Log.i("InstructionVideo", "videoFile name: " +videoFile);

這是該部分的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

它表明,即使我比較它們,它們返回真實但不是

有一個; 在“if”行的末尾,它終止“if”語句,因此始終執行以下塊。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM