Example usage for android.widget PopupWindow dismiss

List of usage examples for android.widget PopupWindow dismiss

Introduction

In this page you can find the example usage for android.widget PopupWindow dismiss.

Prototype

public void dismiss() 

Source Link

Document

Disposes of the popup window.

Usage

From source file:com.survivingwithandroid.pegboard.DreamPinsActivity.java

public void onBackgroundSelected() {
    LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inf.inflate(R.layout.popbkg_layout, null, false);

    final PopupWindow pw = new PopupWindow(v);
    pw.setFocusable(true);/*from w ww.j  av  a 2  s  .  c om*/
    pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);

    TextView changeTxt = (TextView) v.findViewById(R.id.dlgChange);
    TextView resetTxt = (TextView) v.findViewById(R.id.dlgReset);
    TextView cancelTxt = (TextView) v.findViewById(R.id.dlgCancel);
    cancelTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
        }
    });

    resetTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            pinTableFrag.setBackground(R.drawable.tilebkg);
        }
    });

    changeTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            // Start a new Intent to get the picture from the Gallery
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(intent, SELECT_PICTURE);
        }
    });

    pw.showAtLocation(v, Gravity.CENTER, 0, 0);

}

From source file:com.survivingwithandroid.pegboard1.DreamPinsActivity.java

@Override
public void onSaveSelected() {
    closeMenu();/*from w w  w.ja  v a 2s .  c om*/

    LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inf.inflate(R.layout.popsave_layout, null, false);

    final PopupWindow pw = new PopupWindow(v);
    pw.setFocusable(true);
    pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);

    final EditText edt = (EditText) v.findViewById(R.id.edtFileName);

    TextView saveTxt = (TextView) v.findViewById(R.id.dlgSave);
    TextView cancelTxt = (TextView) v.findViewById(R.id.dlgCancel);
    cancelTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
        }
    });

    saveTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            Bitmap b = pinTableFrag.createBitmap();
            try {
                ///////////////
                ImageUtility.saveImage(b, edt.getEditableText().toString(), DreamPinsActivity.this);
                ///////////////

            } catch (SaveFileException sfe) {
                Toast.makeText(DreamPinsActivity.this, getResources().getText(R.string.msgSaveFileError),
                        Toast.LENGTH_LONG).show();
            }
        }
    });

    pw.showAtLocation(v, Gravity.CENTER, 0, 0);

}

From source file:com.zipzapd.DreamPinsActivity.java

@Override
public void onSaveSelected() {
    closeMenu();/*from   www.  j ava  2  s .c  o m*/

    LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inf.inflate(R.layout.popsave_layout, null, false);

    final PopupWindow pw = new PopupWindow(v);
    pw.setFocusable(true);
    pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);

    final EditText edt = (EditText) v.findViewById(R.id.edtFileName);

    TextView saveTxt = (TextView) v.findViewById(R.id.dlgSave);
    TextView cancelTxt = (TextView) v.findViewById(R.id.dlgCancel);
    cancelTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
        }
    });

    saveTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            Bitmap b = pinTableFrag.createBitmap();
            try {
                ///////////////
                ImageUtility.saveImage(b, edt.getEditableText().toString(), DreamPinsActivity.this);

                sync.putZipZapData();
                ///////////////

            } catch (SaveFileException sfe) {
                Toast.makeText(DreamPinsActivity.this, getResources().getText(R.string.msgSaveFileError),
                        Toast.LENGTH_LONG).show();
            }
        }
    });

    pw.showAtLocation(v, Gravity.CENTER, 0, 0);

}

From source file:com.ximai.savingsmore.save.activity.FourStepRegisterActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.submit:
        if (store_name.getText() == null || TextUtils.isEmpty(store_name.getText())) {
            Toast.makeText(FourStepRegisterActivity.this, "??", Toast.LENGTH_SHORT).show();
        } else if (phone_number.getText() == null || TextUtils.isEmpty(phone_number.getText())) {
            Toast.makeText(FourStepRegisterActivity.this, "?", Toast.LENGTH_SHORT).show();
        } else if (address.getmTvRightText() == null || TextUtils.isEmpty(address.getmTvRightText())) {
            Toast.makeText(FourStepRegisterActivity.this, "?", Toast.LENGTH_SHORT).show();
        } else if (xixiang_adress.getText() == null || TextUtils.isEmpty(xixiang_adress.getText())) {
            Toast.makeText(FourStepRegisterActivity.this, "", Toast.LENGTH_SHORT).show();
        } else if (good_type.getmTvRightText() == null || TextUtils.isEmpty(good_type.getmTvRightText())
                || good_type.getmTvRightText().equals("")) {
            Toast.makeText(FourStepRegisterActivity.this, "?", Toast.LENGTH_SHORT).show();
        } else if (good_range.getmTvRightText() == null || TextUtils.isEmpty(good_range.getmTvRightText())
                || good_range.getmTvRightText().equals("")) {
            Toast.makeText(FourStepRegisterActivity.this, "?", Toast.LENGTH_SHORT).show();
        } else if (zhizhao_path == null || TextUtils.isEmpty(zhizhao_path)) {
            Toast.makeText(FourStepRegisterActivity.this, "?", Toast.LENGTH_SHORT).show();
        } else {/*from  w  w  w . j a v a 2s .  c o  m*/
            myUserExtInfo.StoreName = store_name.getText().toString();
            myUserExtInfo.OfficePhone = phone_number.getText().toString();
            myUserExtInfo.WebSite = website.getText().toString();
            userParameter.WeChat = weChat.getText().toString();
            userParameter.Domicile = xixiang_adress.getText().toString();
            myUserExtInfo.FoundingDate = create_date.getmTvRightText();
            myUserExtInfo.BusinessLicenseNumber = zhizhao_number.getText().toString();
            myUserExtInfo.LicenseKeyNumber = zhegnshu_number.getText().toString();
            userParameter.UserDisplayName = lianxiren.getText().toString();
            userParameter.Post = position.getText().toString();
            //list_images.addAll(images);
            myUserExtInfo.Images = images;
            if (good_type.getmTvRightText().equals("???")) {
                myUserExtInfo.IsBag = "true";
            } else {
                myUserExtInfo.IsBag = "false";
            }
            list1.add(myBusinessScopes);
            userParameter.BusinessScopes = list1;
            userParameter.UserExtInfo = myUserExtInfo;
            if (a == b) {
                save_message(userParameter);
            }
        }
        break;
    case R.id.create_time:
        UsePicker.showYearMonthDay(FourStepRegisterActivity.this, new UsePicker.CallBack() {
            @Override
            public void callBack(String time) {
                create_date.getmTvRight_().setText(time);

            }
        }, create_date.getmTvRightText());
        break;
    case R.id.head_image:
        isslinece = false;
        isItem = false;
        isheadImage = true;
        isZhengshu = false;
        showSetIconWindow();
        break;

    case R.id.good_type:
        PopupWindowFromBottomUtil.shouWindowWithWheel(
                FourStepRegisterActivity.this, LayoutInflater.from(FourStepRegisterActivity.this)
                        .inflate(R.layout.business_my_center_activity, null),
                list_type, new PopupWindowFromBottomUtil.Listener() {
                    @Override
                    public void confirm(String content, PopupWindow window) {
                        good_type.getmTvRight_().setText(content);
                        window.dismiss();
                    }
                });
        break;
    case R.id.range:
        if (good_type.getmTvRightText().equals("???")) {
            PopupWindowFromBottomUtil.shouRange(FourStepRegisterActivity.this,
                    LayoutInflater.from(FourStepRegisterActivity.this)
                            .inflate(R.layout.business_my_center_activity, null),
                    good_one_classify, new PopupWindowFromBottomUtil.Listener2() {
                        @Override
                        public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                            good_range.getmTvRight_().setText(content);
                            //                            myDictNode.Name = Id1.Name;
                            //                            myDictNode.SortNo = Id1.SortNo;
                            //                            myDictNode.Id=Id1.Id;
                            myBusinessScopes.DictNodeId = Id1.Id;
                            popupWindow.dismiss();
                        }
                    });
        } else {
            PopupWindowFromBottomUtil.shouRange(FourStepRegisterActivity.this,
                    LayoutInflater.from(FourStepRegisterActivity.this)
                            .inflate(R.layout.business_my_center_activity, null),
                    good_two_classify, new PopupWindowFromBottomUtil.Listener2() {
                        @Override
                        public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                            good_range.getmTvRight_().setText(content);
                            //                            myDictNode.Name = Id1.Name;
                            //                            myDictNode.SortNo = Id1.SortNo;
                            //                            myDictNode.Id=Id1.Id;
                            myBusinessScopes.DictNodeId = Id1.Id;
                            popupWindow.dismiss();
                        }
                    });
        }
        break;
    case R.id.adress:
        PopupWindowFromBottomUtil.showAddress(
                FourStepRegisterActivity.this, LayoutInflater.from(FourStepRegisterActivity.this)
                        .inflate(R.layout.business_my_center_activity, null),
                list, new PopupWindowFromBottomUtil.Listenre1() {
                    @Override
                    public void callBack(String Id1, String Id2, String Id3, String content,
                            PopupWindow popupWindow) {
                        if (null != Id1) {
                            userParameter.ProvinceId = Id1;
                        }
                        if (null != Id2) {
                            userParameter.CityId = Id2;
                        }
                        if (null != Id3) {
                            userParameter.AreaId = Id3;
                        }
                        address.getmTvRight_().setText(content);
                        popupWindow.dismiss();
                    }

                });
        break;
    case R.id.liscense_item:
        isslinece = true;
        isItem = false;
        isheadImage = false;
        isZhengshu = false;
        showSetIconWindow();
        break;
    case R.id.zhengshu_item:
        isItem = false;
        isheadImage = false;
        isslinece = false;
        isZhengshu = true;
        showSetIconWindow();
        break;
    case R.id.btnCancel:
        setIconWindow.dismiss();
        break;
    case R.id.btnCamera:
        openCamera();
        setIconWindow.dismiss();
        break;
    case R.id.btnAlbum:
        openAlbum();
        setIconWindow.dismiss();
        break;
    }
}

From source file:cc.echonet.coolmicapp.MainActivity.java

private void goAbout() {

    Log.d("MainActivity", "goAbout() ");

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View popUpView = inflater.inflate(R.layout.popup_about, null, false);

    final PopupWindow popUp = new PopupWindow(this);

    Button close = (Button) popUpView.findViewById(R.id.cmdPopUpDismiss);
    close.setOnClickListener(new View.OnClickListener() {
        public void onClick(View popupView) {
            popUp.dismiss();
        }/*from  w w  w  .  ja  v  a  2 s  .  c  o  m*/
    });

    ((TextView) popUpView.findViewById(R.id.txtVersion)).setText(BuildConfig.VERSION_NAME);
    ((TextView) popUpView.findViewById(R.id.txtBuildType)).setText(BuildConfig.BUILD_TYPE);
    ((TextView) popUpView.findViewById(R.id.txtGITBranch)).setText(BuildConfig.GIT_BRANCH);
    ((TextView) popUpView.findViewById(R.id.txtGITRevision)).setText(BuildConfig.GIT_REVISION);
    ((TextView) popUpView.findViewById(R.id.txtGITAuthor)).setText(BuildConfig.GIT_AUTHOR);
    ((TextView) popUpView.findViewById(R.id.txtGITDirty)).setText(BuildConfig.GIT_DIRTY);

    popUpView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

    popUp.setContentView(popUpView);

    Log.d("MainActivity", String.format("h: %s w: %s h: %s w: %s", popUp.getHeight(), popUp.getWidth(),
            popUpView.getMeasuredHeight(), popUpView.getMeasuredWidth()));

    popUp.setHeight(popUpView.getMeasuredHeight());
    popUp.setWidth(popUpView.getMeasuredWidth());

    popUp.showAtLocation(popUpView, Gravity.CENTER, 0, 0);

    Log.d("MainActivity", "goAbout() end ");
}

From source file:com.ximai.savingsmore.save.activity.BusinessMyCenterActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.submit:
        if (store_name.getText() == null || TextUtils.isEmpty(store_name.getText())) {
            Toast.makeText(BusinessMyCenterActivity.this, "??", Toast.LENGTH_SHORT).show();
        } else if (phone_number.getText() == null || TextUtils.isEmpty(phone_number.getText())) {
            Toast.makeText(BusinessMyCenterActivity.this, "?", Toast.LENGTH_SHORT).show();
        }//w w w .jav a 2 s .  c  o m

        //                else if (website.getText() == null || TextUtils.isEmpty(website.getText())) {
        //                    Toast.makeText(BusinessMyCenterActivity.this, "", Toast.LENGTH_SHORT).show();
        //                } else if (weChat.getText() == null || TextUtils.isEmpty(weChat.getText())) {
        //                    Toast.makeText(BusinessMyCenterActivity.this, "", Toast.LENGTH_SHORT).show();
        //                }

        else if (address.getmTvRightText() == null || TextUtils.isEmpty(address.getmTvRightText())) {
            Toast.makeText(BusinessMyCenterActivity.this, "?", Toast.LENGTH_SHORT).show();
        } else if (xixiang_adress.getText() == null || TextUtils.isEmpty(xixiang_adress.getText())) {
            Toast.makeText(BusinessMyCenterActivity.this, "", Toast.LENGTH_SHORT).show();
        } else if (create_date.getmTvRightText() == null || TextUtils.isEmpty(create_date.getmTvRightText())) {
            Toast.makeText(BusinessMyCenterActivity.this, "??", Toast.LENGTH_SHORT)
                    .show();
        } else if (zhizhao_number.getText() == null || TextUtils.isEmpty(zhizhao_number.getText())) {
            Toast.makeText(BusinessMyCenterActivity.this, "???", Toast.LENGTH_SHORT)
                    .show();
        } else if (zhegnshu_number.getText() == null || TextUtils.isEmpty(zhegnshu_number.getText())) {
            Toast.makeText(BusinessMyCenterActivity.this, "????", Toast.LENGTH_SHORT).show();
        } else if (xukezheng_path == null || TextUtils.isEmpty(xukezheng_path)) {
            Toast.makeText(BusinessMyCenterActivity.this, "??", Toast.LENGTH_SHORT)
                    .show();
        } else if (position.getText() == null || TextUtils.isEmpty(position.getText())) {
            Toast.makeText(BusinessMyCenterActivity.this, "???", Toast.LENGTH_SHORT).show();
        } else if (xiliren_number.getText() == null || TextUtils.isEmpty(xiliren_number.getText())) {
            Toast.makeText(BusinessMyCenterActivity.this, "?", Toast.LENGTH_SHORT)
                    .show();
        } else if (lianxiren.getText() == null || TextUtils.isEmpty(lianxiren.getText())) {
            Toast.makeText(BusinessMyCenterActivity.this, "?", Toast.LENGTH_SHORT).show();
        } else if (good_type.getmTvRightText() == null || TextUtils.isEmpty(good_type.getmTvRightText())
                && good_type.getmTvRightText().equals("")) {
            Toast.makeText(BusinessMyCenterActivity.this, "?", Toast.LENGTH_SHORT).show();
        } else if (good_range.getmTvRightText() == null || TextUtils.isEmpty(good_range.getmTvRightText())
                && good_range.getmTvRightText().equals("")) {
            Toast.makeText(BusinessMyCenterActivity.this, "?", Toast.LENGTH_SHORT).show();
        } else if (zhizhao_path == null || TextUtils.isEmpty(zhizhao_path)) {
            Toast.makeText(BusinessMyCenterActivity.this, "?", Toast.LENGTH_SHORT).show();
        } else {
            myUserExtInfo.StoreName = store_name.getText().toString();
            myUserExtInfo.OfficePhone = phone_number.getText().toString();
            myUserExtInfo.WebSite = website.getText().toString();
            userParameter.WeChat = weChat.getText().toString();
            userParameter.Domicile = xixiang_adress.getText().toString();
            myUserExtInfo.FoundingDate = create_date.getmTvRightText();
            myUserExtInfo.BusinessLicenseNumber = zhizhao_number.getText().toString();
            myUserExtInfo.LicenseKeyNumber = zhegnshu_number.getText().toString();
            userParameter.UserDisplayName = lianxiren.getText().toString();
            userParameter.Post = position.getText().toString();
            list_images.addAll(images);
            myUserExtInfo.Images = list_images;
            if (good_type.getmTvRightText().equals("???")) {
                myUserExtInfo.IsBag = "true";
            } else {
                myUserExtInfo.IsBag = "false";
            }
            list1.add(myBusinessScopes);
            userParameter.BusinessScopes = list1;
            userParameter.UserExtInfo = myUserExtInfo;
            if (a == b) {
                save_message(userParameter);
            }
        }
        break;
    case R.id.create_time:
        UsePicker.showYearMonthDay(BusinessMyCenterActivity.this, new UsePicker.CallBack() {
            @Override
            public void callBack(String time) {
                create_date.getmTvRight_().setText(time);
                myUserExtInfo.FoundingDate = time;
            }
        }, create_date.getmTvRightText());
        break;
    case R.id.yingye_start:
        UsePicker.showHuors(BusinessMyCenterActivity.this, new UsePicker.CallBack() {
            @Override
            public void callBack(String time) {
                yingye_start.getmTvRight_().setText(time);
                myUserExtInfo.StartHours = time;
            }
        }, yingye_start.getmTvRightText());
        break;
    case R.id.yingye_end:
        UsePicker.showHuors(BusinessMyCenterActivity.this, new UsePicker.CallBack() {
            @Override
            public void callBack(String time) {
                yingye_end.getmTvRight_().setText(time);
                myUserExtInfo.EndHours = time;
            }
        }, yingye_end.getmTvRightText());
        break;
    case R.id.head_image:
        isslinece = false;
        isItem = false;
        isheadImage = true;
        isZhengshu = false;
        showSetIconWindow();
        break;

    case R.id.good_type:
        PopupWindowFromBottomUtil.shouWindowWithWheel(
                BusinessMyCenterActivity.this, LayoutInflater.from(BusinessMyCenterActivity.this)
                        .inflate(R.layout.business_my_center_activity, null),
                list_type, new PopupWindowFromBottomUtil.Listener() {
                    @Override
                    public void confirm(String content, PopupWindow window) {
                        good_type.getmTvRight_().setText(content);
                        window.dismiss();
                    }
                });
        break;
    case R.id.range:
        if (good_type.getmTvRightText().equals("???")) {
            PopupWindowFromBottomUtil.shouRange(BusinessMyCenterActivity.this,
                    LayoutInflater.from(BusinessMyCenterActivity.this)
                            .inflate(R.layout.business_my_center_activity, null),
                    good_one_classify, new PopupWindowFromBottomUtil.Listener2() {
                        @Override
                        public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                            good_range.getmTvRight_().setText(content);
                            //                            myDictNode.Name = Id1.Name;
                            //                            myDictNode.SortNo = Id1.SortNo;
                            //                            myDictNode.Id=Id1.Id;
                            myBusinessScopes.DictNodeId = Id1.Id;
                            popupWindow.dismiss();
                        }
                    });
        } else {
            PopupWindowFromBottomUtil.shouRange(BusinessMyCenterActivity.this,
                    LayoutInflater.from(BusinessMyCenterActivity.this)
                            .inflate(R.layout.business_my_center_activity, null),
                    good_two_classify, new PopupWindowFromBottomUtil.Listener2() {
                        @Override
                        public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                            good_range.getmTvRight_().setText(content);
                            //                            myDictNode.Name = Id1.Name;
                            //                            myDictNode.SortNo = Id1.SortNo;
                            //                            myDictNode.Id=Id1.Id;
                            myBusinessScopes.DictNodeId = Id1.Id;
                            popupWindow.dismiss();
                        }
                    });
        }
        break;
    case R.id.adress:
        PopupWindowFromBottomUtil.showAddress(
                BusinessMyCenterActivity.this, LayoutInflater.from(BusinessMyCenterActivity.this)
                        .inflate(R.layout.business_my_center_activity, null),
                list, new PopupWindowFromBottomUtil.Listenre1() {
                    @Override
                    public void callBack(String Id1, String Id2, String Id3, String content,
                            PopupWindow popupWindow) {
                        if (null != Id1) {
                            userParameter.ProvinceId = Id1;
                        }
                        if (null != Id2) {
                            userParameter.CityId = Id2;
                        }
                        if (null != Id3) {
                            userParameter.AreaId = Id3;
                        }
                        address.getmTvRight_().setText(content);
                        popupWindow.dismiss();
                    }

                });
        break;
    case R.id.liscense_item:
        isslinece = true;
        isItem = false;
        isheadImage = false;
        isZhengshu = false;
        showSetIconWindow();
        break;
    case R.id.zhengshu_item:
        isItem = false;
        isheadImage = false;
        isslinece = false;
        isZhengshu = true;
        showSetIconWindow();
        break;
    case R.id.btnCancel:
        setIconWindow.dismiss();
        break;
    case R.id.btnCamera:
        openCamera();
        setIconWindow.dismiss();
        break;
    case R.id.btnAlbum:
        openAlbum();
        setIconWindow.dismiss();
        break;
    }
}

From source file:com.lines.activitys.SettingsActivity.java

/**
 * This method creates and shows a popup to the user, displaying a relevent
 * help message.//from w w w . ja  v  a 2s  . com
 * 
 * @param msg
 *            - decides which message we are displaying to the user
 * 
 */
private void showPopup(String msg) {
    // Create popup
    LayoutInflater layoutInflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
    View popupView = layoutInflater.inflate(R.layout.help_popup_layout, null);
    final PopupWindow popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);

    Button btnDismiss = (Button) popupView.findViewById(R.id.dismiss);
    TextView text = (TextView) popupView.findViewById(R.id.text);

    // Here we decide what help message to display to the user.
    if (msg.equals("prompts")) {
        text.setText(R.string.prompt_help);
    } else {
        text.setText(R.string.auto_help);
    }

    btnDismiss.setOnClickListener(new Button.OnClickListener() {

        public void onClick(View v) {
            popupWindow.dismiss();
        }
    });

    popupWindow.showAsDropDown(mPrompts, 50, -150);
}

From source file:fr.univsavoie.ltp.client.map.Popup.java

/**
  * Afficher sur la map un popup qui affiche les
  * informations de l'utilisateur connect.
  *///from  w  w  w  .  ja  v  a2  s  .  co m
public final void popupDisplayUserInfos() {
    DisplayMetrics dm = new DisplayMetrics();
    this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

    //final int height = dm.heightPixels;
    final int width = dm.widthPixels;

    int popupWidth = (int) (width * 0.75);
    //int popupHeight = height / 2;

    // Inflate the popup_layout.xml
    LinearLayout viewGroup = (LinearLayout) this.activity.findViewById(R.id.popupAccount);
    LayoutInflater layoutInflater = (LayoutInflater) this.activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View layout = layoutInflater.inflate(R.layout.popup_account, viewGroup);
    layout.setBackgroundResource(R.drawable.popup_gradient);

    // Crer le PopupWindow
    final PopupWindow popupUserInfos = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true);
    popupUserInfos.setBackgroundDrawable(new BitmapDrawable());
    popupUserInfos.setOutsideTouchable(true);

    // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
    final int OFFSET_X = 0;
    final int OFFSET_Y = 0;

    // Displaying the popup at the specified location, + offsets.
    this.activity.findViewById(R.id.layoutMain).post(new Runnable() {
        public void run() {
            popupUserInfos.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y);
        }
    });

    /*
     * Evenements composants du PopupWindow
     */

    // Ecouteur d'vnement sur le bouton pour se dconnecter
    Button close = (Button) layout.findViewById(R.id.close);
    close.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            popupUserInfos.dismiss();
        }
    });
}

From source file:com.lines.activitys.OptionsActivity.java

/**
 * This method creates and shows a popup to the user, displaying a relevent
 * help message./*from  w  w w.  j av  a2  s.  co  m*/
 * 
 * @param msg
 *            - decides which message we are displaying to the user
 * 
 */
private void showPopup(String msg) {
    // Create popup
    LayoutInflater layoutInflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
    View popupView = layoutInflater.inflate(R.layout.help_popup_layout, null);
    final PopupWindow popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);

    Button btnDismiss = (Button) popupView.findViewById(R.id.dismiss);
    TextView text = (TextView) popupView.findViewById(R.id.text);

    // Here we decide what help message to display to the user.
    if (msg.equals("cue")) {
        text.setText(R.string.cue_help);
    } else if (msg.equals("random")) {
        text.setText(R.string.random_help);
    } else if (msg.equals("own line")) {
        text.setText(R.string.own_line_help);
    } else if (msg.equals("stage")) {
        text.setText(R.string.stage_help);
    } else if (msg.equals("mode")) {
        text.setText(R.string.mode_help);
    }

    btnDismiss.setOnClickListener(new Button.OnClickListener() {

        public void onClick(View v) {
            popupWindow.dismiss();
        }
    });

    popupWindow.showAsDropDown(mCueHelp, 50, -250);
}

From source file:com.ximai.savingsmore.save.activity.AddGoodsAcitivyt.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.servise:
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_CALL);
        intent.setData(Uri.parse("tel:" + "58366991"));
        startActivity(intent);//from   w ww. j a v  a 2s .com
        break;

    case R.id.one_classity:
        PopupWindowFromBottomUtil.shouRange(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                good_one_classify, new PopupWindowFromBottomUtil.Listener2() {
                    @Override
                    public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                        yijifenlei.setTextColor(getResources().getColor(R.color.text_black));
                        yijifenlei.setText(Id1.Name);
                        myProduct.FirstClassId = Id1.Id;
                        oneId = Id1.Id;
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.two_classity:
        if (null != oneId && !TextUtils.isEmpty(oneId)) {
            good_two_classify.clear();
            for (int i = 0; i < list.size(); i++) {
                if (null != list.get(i).Name && null != list.get(i).ParentId && null != list.get(i).Id
                        && list.get(i).ParentId.equals(oneId)) {
                    good_two_classify.add(list.get(i));
                }
            }
            PopupWindowFromBottomUtil.shouRange(
                    AddGoodsAcitivyt.this, LayoutInflater.from(AddGoodsAcitivyt.this)
                            .inflate(R.layout.business_my_center_activity, null),
                    good_two_classify, new PopupWindowFromBottomUtil.Listener2() {
                        @Override
                        public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                            erjifenlei.setTextColor(getResources().getColor(R.color.text_black));
                            erjifenlei.setText(Id1.Name);
                            myProduct.SecondClassId = Id1.Id;
                            popupWindow.dismiss();
                        }
                    });
        } else {
            Toast.makeText(AddGoodsAcitivyt.this, "", Toast.LENGTH_SHORT).show();
        }
        break;
    case R.id.brand_name:
        PopupWindowFromBottomUtil.shouRange(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                brand_list, new PopupWindowFromBottomUtil.Listener2() {
                    @Override
                    public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                        brand.setTextColor(getResources().getColor(R.color.text_black));
                        brand.setText(Id1.Name);
                        myProduct.BrandId = Id1.Id;
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.xingshi_item:
        PopupWindowFromBottomUtil.shouSalesType(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                goodSalesTypes, new PopupWindowFromBottomUtil.Listenrt3() {
                    @Override
                    public void callback(GoodSalesType goodSalesType, PopupWindow popupWindow) {
                        myProduct.PromotionType = goodSalesType.Id;
                        yuan_price.setText("");
                        cuxiao_price.setText("");
                        cuxiao_text.setText("");
                        xingshi.setTextColor(getResources().getColor(R.color.text_black));
                        xingshi.setText(goodSalesType.Value);
                        xingshi_id = goodSalesType.Id;
                        if (goodSalesType.Id.equals("5")) {
                            yuan_price.setText("10");
                            cuxiao_price.setText("10");
                        } else if (goodSalesType.Id.equals("6")) {
                            yuan_price.setText("1");
                            cuxiao_price.setText("1");
                        } else if (goodSalesType.Id.equals("11")) {
                            yuan_price.setText("0");
                            cuxiao_price.setText("0");
                        } else if (goodSalesType.Id.equals("2")) {
                            cuxiao_text.setText("N?N");

                        }
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.dizhi_item:
        PopupWindowFromBottomUtil.showAddress(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                list, new PopupWindowFromBottomUtil.Listenre1() {
                    @Override
                    public void callBack(String Id1, String Id2, String Id3, String content,
                            PopupWindow popupWindow) {
                        myProduct.ProvinceId = Id1;
                        myProduct.CityId = Id2;
                        myProduct.AreaId = Id3;
                        dizhi.setTextColor(getResources().getColor(R.color.text_black));
                        dizhi.setText(content);
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.start_time_item:
        UsePicker.showAll(AddGoodsAcitivyt.this, new UsePicker.CallBack() {
            @Override
            public void callBack(String time) {
                SimpleDateFormat dd = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                Date date1 = null;
                try {
                    date1 = dd.parse(time);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                Long time1 = date1.getTime();
                Date dt = new Date();
                Long now = dt.getTime();
                if (now > time1) {
                    Toast.makeText(AddGoodsAcitivyt.this, "??",
                            Toast.LENGTH_SHORT).show();
                } else {
                    start_date = time;
                    myProduct.StartTime = time;
                    start.setTextColor(getResources().getColor(R.color.text_black));
                    start.setText(time);
                }
            }
        }, start.getText().toString());
        break;
    case R.id.end_time_item:
        UsePicker.showAll(AddGoodsAcitivyt.this, new UsePicker.CallBack() {
            @Override
            public void callBack(String time) {
                SimpleDateFormat dd = new SimpleDateFormat("yyyy-MM-dd");

                try {
                    Date date1 = dd.parse(start_date);
                    Date date2 = dd.parse(time);
                    Long time1 = date1.getTime();
                    Long time2 = date2.getTime();
                    if ((time2 > time1)) {
                        myProduct.EndTime = time;
                        end.setTextColor(getResources().getColor(R.color.text_black));
                        end.setText(time);
                    } else {
                        Toast.makeText(AddGoodsAcitivyt.this, "??",
                                Toast.LENGTH_SHORT).show();
                    }
                } catch (ParseException e) {
                    e.printStackTrace();
                }

            }
        }, end.getText().toString());
        break;
    case R.id.danwei_item:
        PopupWindowFromBottomUtil.shouRange(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                danwei_list, new PopupWindowFromBottomUtil.Listener2() {
                    @Override
                    public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                        myProduct.UnitId = Id1.Id;
                        danwei.setTextColor(getResources().getColor(R.color.text_black));
                        danwei.setText(Id1.Name);
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.bizhong_item:
        PopupWindowFromBottomUtil.shouRange(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                bizhong_list, new PopupWindowFromBottomUtil.Listener2() {
                    @Override
                    public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                        myProduct.CurrencyId = Id1.Id;
                        bizhong.setTextColor(getResources().getColor(R.color.text_black));
                        bizhong.setText(Id1.Name);
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.fapiao_item:
        PopupWindowFromBottomUtil.shouRange(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                fapiao_list, new PopupWindowFromBottomUtil.Listener2() {
                    @Override
                    public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                        myProduct.InvoiceId = Id1.Id;
                        fapiao.setTextColor(getResources().getColor(R.color.text_black));
                        fapiao.setText(Id1.Name);
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.btnCancel:
        setIconWindow.dismiss();
        break;
    case R.id.btnCamera:
        openCamera();
        setIconWindow.dismiss();
        break;
    case R.id.btnAlbum:
        openAlbum();
        setIconWindow.dismiss();
        break;
    case R.id.fabu:
        myProduct.Name = my_name.getText().toString();
        myProduct.Name = product_name.getText().toString();
        myProduct.Number = product_bianhao.getText().toString();
        myProduct.Address = xiangxi_address.getText().toString();
        myProduct.OriginalPrice = yuan_price.getText().toString();
        myProduct.Price = cuxiao_price.getText().toString();
        myProduct.Introduction = explain.getText().toString();
        myProduct.Description = explain.getText().toString();
        myProduct.Images = images;
        if (myProduct.Images.size() > 0 && null != myProduct.Name && null != myProduct.CityId
                && null != myProduct.InvoiceId && null != myProduct.Address && null != myProduct.AreaId
                && null != myProduct.BrandId && null != myProduct.CurrencyId && null != myProduct.CityId
                && null != myProduct.Description && null != myProduct.EndTime && null != myProduct.Description
                && null != myProduct.FirstClassId && null != myProduct.SecondClassId
                && null != myProduct.Description) {
            saveMyProduct(myProduct);
        } else {
            Toast.makeText(AddGoodsAcitivyt.this, "?", Toast.LENGTH_SHORT).show();
        }

        break;

    }
}