2013-12-10 50 views
0

嗨,我正在使用android遊戲。我在我的應用程序中添加了Google AdView(橫幅小尺寸)。但是現在我正在尋找將彈出式adView添加到我的應用程序中的一些活動。如何將彈出式AdView添加到我的應用程序中。 ??請幫助,因爲我是新來的Android應用程序,並感謝你..如何添加彈出式addview到我的android應用程序?

回答

0

嘗試了這一點:

聲明:

private View popupView; 
private PopupWindow popupWindow; 

使用此代碼在您的onCreate

LayoutInflater layoutInflater = (LayoutInflater) getBaseContext() 
      .getSystemService(LAYOUT_INFLATER_SERVICE); 
    popupView = layoutInflater.inflate(R.layout.menu_popup, null); 
    popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, 
      LayoutParams.WRAP_CONTENT); 
    popupWindow.setBackgroundDrawable(getResources().getDrawable(
      android.R.color.transparent)); 
    popupWindow.setOutsideTouchable(true); 
    popupWindow.setTouchable(true); 
    popupWindow.showAsDropDown(findViewById(R.id.topMenu)); 

你可以添加任何自定義佈局,並用R.layout.menu_popup替換它

+0

什麼是您在此使用的topMenu? – ptm

+0

@Chagu它是任何視圖。我的意圖是將彈出視圖顯示爲在我的佈局中特定的「topmenu」下方。你也可以使用'popUp.showAtLocation(mainLayout,Gravity.BOTTOM,10,10);' –

相關問題