2011-11-11 41 views
0

我有一個簡單的Android應用程序,它搜索。我有一個自定義彈出窗口來選擇過濾器。如何在android中以編程方式打開自定義彈出窗口?

我現在正在開發一個主屏幕應用程序小部件。應用程序小部件與Android的Google搜索小部件類似。

有一個過濾器彈出,一個搜索框(假)和一個搜索按鈕(而不是谷歌的聲音按鈕)。

除了彈出窗口,一切都很好。

當過濾器按鈕被點擊一個小部件時,我觸發了一個額外的意圖,表示主頁按鈕被點擊。

當活動打開時,我檢查應該打開彈出窗口的按鈕上的extra和performClick()。但這不起作用。任何想法?

我的代碼是這樣的 -

在我的窗口小部件 -

Intent intent = new Intent(context, ActivityToOpen.class); 

Bundle bundle = new Bundle(); 
bundle.putBoolean(CALL_FROM_WIDGET, true); 
bundle.putBoolean(HOME_BUTTON_CLICKED, true); 
intent.putExtras(loginBundle); 
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); 

在我的活動 -

Bundle b = getIntent().getExtras(); 
if(b != null && b.getBoolean(CMWidget.HOME_BUTTON_CLICKED)) { 
home_button.performClick(); 
} 

我有一個onClickListener設置是這樣的 -

home_button = findViewById(R.id.home_button); 
home_button.setOnClickListener(new OnClickListener() { 

i have implemented onClick() here which pops up the custom popup menu. Popup menu has Quick Action Items. 

}); 
+0

你可以發表你的代碼嗎?沒有代碼就很難找到問題。 – Shaireen

+0

我有問題更新的代碼。 – Enigma

+0

好友你已經發布了所有的代碼,但沒有問題..你如何實現自定義彈出?它可能有一些問題 – Shaireen

回答

-1

我正在尋找這個沒人回答的問題。

Bundle b = getIntent().getExtras(); 
if(b != null && b.getBoolean(CMWidget.HOME_BUTTON_CLICKED)) { 
findViewById(R.id.anchor_button).post(new Runnable() { 
      @Override 
      public void run() { 
       showPopup(); 
      } 
} 
相關問題