문제

Hi I am working with android games.I added Google AdView(banner small size) to my application.But now I am looking to add popup adView to my application for some activities.How can I add popup AdView to my app .??? please help since I am new to android app and thank you..

도움이 되었습니까?

해결책

Try this out :

Declaration :

private View popupView;
private PopupWindow popupWindow;

Use this code in your 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));

You can add any custom layout and replace it with R.layout.menu_popup

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top