How can I add popup addview to my android app?

383 views Asked by At

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..

1

There are 1 answers

2
Rethinavel On BEST ANSWER

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