2016-10-28 4 views
0

문자열이 전달되지만 null로 가져오고 else 부분을 실행합니다. 왜 null인지 확인하십시오. 내 코드는 여기에 있습니다.if else if if else if if else statement if else else if if else statement if else else if if else statement if else else if if else statement if else else if if else statement if else else if if else statement if else else if 조건문을 if else 문에 전달하고 null로 설정하고 else 부분을 android 응용 프로그램에서 실행 중입니다.

if(HallTicket_Status.equals("HETSTOP")) 
    { 
    android.app.AlertDialog alertDialog = new android.app.AlertDialog.Builder(
    UpcomingEventsDetails.this).create(); 
    alertDialog.setTitle("Hall Ticket Generation Stopped!"); 
    alertDialog.setMessage("Hall Ticket generation for this event has been stopped. You can apply for other events, if you meet the eligibility criteria."); 
    alertDialog.setIcon(R.drawable.tick); 
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int which) {} 
    }); 
    } 
    else if (HallTicket_Status.equals("NE")) { 
    Toast toast = Toast.makeText(UpcomingEventsDetails.this, "NOT ELIGIBLE", Toast.LENGTH_LONG); 
    toast.setGravity(Gravity.CENTER, 0, 0); 
    toast.show(); 
    } 
    else if (HallTicket_Status.equals("PNC")) { 
    Toast toast = Toast.makeText(UpcomingEventsDetails.this, "Please Check Your Profile", Toast.LENGTH_LONG); 
    toast.setGravity(Gravity.CENTER, 0, 0); 
    toast.show(); 
    } 
    else if(HallTicket_Status.equals("NPU")){ 
    Context context = getApplicationContext(); 
    CharSequence text = "This event is only for COSET subscribers,for more details please login into http://costuco.coset.com"; 
    int duration = Toast.LENGTH_LONG; 
    Toast toast = Toast.makeText(context, text, duration); 
    toast.show(); 
    } 
    else { 
    Intent intent=new Intent(UpcomingEventsDetails.this,Hallticket.class); 
    intent.putExtra("EVENT_ID",eventid); 
    intent.putExtra("het_uid",b); 
    Log.d("#$Request URL", eventid + ""); 
    Log.d("###$Response ", b + ""); 
    startActivity(intent); 
    } 
    } 

답변

0

변화 HallTicket_Status.equalsIgnoreCase ("HETSTOP")에 HallTicket_Status.equals ("HETSTOP")

이 경우

+0

마음이 우리에게하는 모든 경우에 위해를 수행 ** 왜 * * ?! https://www.tutorialspoint.com/java/java_string_equalsignorecase.htm –

+0

나는 시도했다. 그러나 "HETSTOP"대신 널 값 –

+0

을 사용하여 오류 로그를 공유 할 수있다. – EKN