Create PopupWindow - Android User Interface

Android examples for User Interface:Window

Description

Create PopupWindow

Demo Code


//package com.java2s;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;

import android.widget.PopupWindow;

public class Main {
    public static PopupWindow getPopupWindow(View view,
            Drawable backgroundDrawable, Context context, int width,
            int height) {
        PopupWindow popupWindow = new PopupWindow(context);
        popupWindow.setContentView(view);
        popupWindow.setBackgroundDrawable(backgroundDrawable);
        popupWindow.setWidth(width);/* www.  ja v a2 s .co  m*/
        popupWindow.setHeight(height);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setFocusable(true);
        popupWindow.update();
        return popupWindow;
    }
}

Related Tutorials