2011-07-28 41 views
0

我有一個活動被2個意圖調用,一個簡單的菜單選擇之後,另一個意圖刪除一個數據庫中的項目。但是,我想在被叫活動中顯示一個小吐司,但只有當它通過刪除的意圖打開時。我想以下解決方案試圖在活動被意圖打開後嘗試做吐司

public void intentCheck(){ 
    Log.d("ShowActivity","intentCheck() called"); 
    Bundle extras = getIntent().getExtras(); 
    if (extras != null){  
      String check = extras.getString("AdvancedViewActivityCall"); 
      if(check == "calling"){ 
       Log.d("ShowActivity","delete-intent succeeded"); 
       Toast success = new Toast(ShowActivity.this); 
       success.makeText(ShowActivity.this, "Deletion succeded", Toast.LENGTH_LONG); 

      } 
     } 

但它不工作......不知何故,沒有吐司得到顯示。

編輯://我申請了success.show();現在,但現在我得到一個RunetimeException O.o(http://pastebin.com/Th3NY5d0

編輯:解:Toast.makeText(context, text, duration).show(); //seems to be the "static way", which eclipse proposed

回答

1

您是否嘗試過if ("calling".equals(check))代替if(check == "calling")

編輯: 嘗試Toast.makeText(context, text, duration).show();

+0

沒了,給我第二.. 編輯://不起作用.. – Aeefire

+0

我甚至可以返回「刪除-ntent成功」像這樣「呼叫」 =檢查,只是不知何故沒有按」 t開始敬酒.. eclipse引發了一些注意,靜態的.makeText應該以靜態方式訪問 – Aeefire

+0

您的編輯,是它!謝謝!但是它似乎與「靜態引用」的日食暗示有關 – Aeefire

1

你要調用的敬酒表演方法,直到否則吐司將不顯示。

success.show(); 
+0

arghhhhh多麼愚蠢的錯誤,對不起,那個rofl – Aeefire

+0

lol,我申請了success.show();現在,但現在得到一個RunetimeException – Aeefire

+0

你可以在logcat中發佈錯誤? – deepa

相關問題