Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;

import android.widget.ImageView;
import android.widget.PopupWindow;

public class Main {
    private static PopupWindow pop = null;

    public static void showPopWindow(Context context, View parent, int drawableId) {
        if (drawableId == 0) {
            return;
        }
        if (pop == null) {
            ImageView imageView = null;
            imageView = new ImageView(context);
            imageView.setBackgroundResource(drawableId);
            pop = new PopupWindow(imageView, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
            imageView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (pop != null) {
                        pop.dismiss();
                        pop = null;
                    }
                }
            });
        }
        if (!pop.isShowing()) {
            pop.showAtLocation(parent, Gravity.BOTTOM, 0, 0);

        }
    }
}