2014-10-03 9 views
-2
public void onclick(View v) 
{ 

    { 
     if (date.equals("30/10/2014")); 
     Intent i = new Intent (this, A3.class); 
     startActivity(i); 
    } 

    if (date.equals("31/10/2014")); 
    Intent r = new Intent (this, A4.class); 
    startActivity(r); 
} 
} 
} 

我需要按鈕檢查,如果文本視圖包含日期例如「10/10/2014」去活動A3 如果文本視圖包含日期「2014年10月10日」轉到活動A4Android:我需要按鈕來比較文本視圖日期和去新的活動,我的代碼不工作

+0

這是甚至編譯?什麼與額外的大括號? – BenjaminPaul 2014-10-03 12:48:00

+0

只是檢查你的代碼這麼多的語法錯誤 – 2014-10-03 12:51:10

回答

2

您在問題中輸入的代碼很奇怪,所以我不確定我的答案是否會幫助你。

首先要刪除';'在'if'語句結尾處。

事情是這樣的:

public void onclick(View v) 
{ 


if (date.equals("30/10/2014")) 
    { 
    Intent i = new Intent (this, A3.class); 
    startActivity(i); 
    } 

if (date.equals("31/10/2014")) 
    { 
    Intent r = new Intent (this, A4.class); 
    startActivity(r); 
    } 

} 

希望這有助於。

+0

即時通訊對不起,它不要 – 2014-10-03 12:57:19

相關問題