只是如果显示对话框

时间:2017-06-19 06:51:28

标签: android

     String statuss = LoginActivty.review_status;

     Toast.makeText(MainActivity.this, "noman :"+ statuss, Toast.LENGTH_SHORT).show();
     Toast.makeText(MainActivity.this, "shah:"+ LoginActivty.review_status
                , Toast.LENGTH_SHORT).show();

     if(statuss != "Reviewed"){
            ratingDialog();
            //  Toast.makeText(MainActivity.this, "Well come back", Toast.LENGTH_SHORT).show();
    }else if(statuss == "Not_Review") {
        Toast.makeText(MainActivity.this, "Well come back", Toast.LENGTH_SHORT).show();

    }
}

当我静态传递status时,它完美无缺,但是当我动态传递LoginActivty.review_status时,它无效。为什么呢?

1 个答案:

答案 0 :(得分:1)

您应该使用等于()而不是 ==

    if(!statuss.equals("Reviewed"))
    {
            ratingDialog();
        //  Toast.makeText(MainActivity.this, "Well come back", Toast.LENGTH_SHORT).show();
    }else if(statuss.equals("Not_Review")) 
    {
            Toast.makeText(MainActivity.this, "Well come back", Toast.LENGTH_SHORT).show();

    }