List of usage examples for android.widget PopupWindow PopupWindow
public PopupWindow(View contentView, int width, int height)
Create a new non focusable popup window which can display the contentView.
From source file:com.sft.blackcatapp.EnrollSchoolActivity.java
private void showOpenCityPopupWindow(View parent) { if (openCityPopupWindow == null) { LinearLayout popWindowLayout = (LinearLayout) View.inflate(mContext, R.layout.pop_window, null); popWindowLayout.removeAllViews(); // LinearLayout popWindowLayout = new LinearLayout(mContext); popWindowLayout.setOrientation(LinearLayout.VERTICAL); ListView OpenCityListView = new ListView(mContext); OpenCityListView.setDividerHeight(0); OpenCityListView.setCacheColorHint(android.R.color.transparent); OpenCityListView.setOnItemClickListener(new OnItemClickListener() { @Override/* w w w. ja v a 2 s. com*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { OpenCityVO selectCity = openCityList.get(position); System.out.println(selectCity.getName()); cityname = selectCity.getName(); licensetype = ""; schoolname = ""; ordertype = ""; index = 1; obtainNearBySchool(); openCityPopupWindow.dismiss(); openCityPopupWindow = null; } }); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); popWindowLayout.addView(OpenCityListView, param); OpenCityAdapter openCityAdapter = new OpenCityAdapter(mContext, openCityList); OpenCityListView.setAdapter(openCityAdapter); openCityPopupWindow = new PopupWindow(popWindowLayout, 130, LayoutParams.WRAP_CONTENT); } openCityPopupWindow.setFocusable(true); openCityPopupWindow.setOutsideTouchable(true); // Back??? openCityPopupWindow.setBackgroundDrawable(new BitmapDrawable()); openCityPopupWindow.showAsDropDown(parent); }
From source file:com.abc.driver.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (menu_display) { menuWindow.dismiss();//w ww. ja v a 2 s . c om menu_display = false; } else { onBackPressed(); } } else if (keyCode == KeyEvent.KEYCODE_MENU) { if (!menu_display) { inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); layout = inflater.inflate(R.layout.main_menu, null); menuWindow = new PopupWindow(layout, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); menuWindow.showAtLocation(this.findViewById(R.id.mainweixin), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); mClose = (LinearLayout) layout.findViewById(R.id.menu_close); mCloseBtn = (LinearLayout) layout.findViewById(R.id.menu_close_btn); mCloseBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(); menuWindow.dismiss(); } }); menu_display = true; } else { menuWindow.dismiss(); menu_display = false; } return false; } return false; }
From source file:com.IntimateCarCare.MainActivity.java
protected void initPopuptWindow() { View view = getLayoutInflater().inflate(R.layout.popupview_gray, null, false); ListView listview = (ListView) view.findViewById(R.id.listview); list = new ArrayList<String>(); for (int i = 0; i < carset.getSize(); i++) { list.add(carset.getItem(i).getCar_num()); }//from ww w .j a va 2 s . c o m // ??? list.add(""); final String[] mStrings = (String[]) list.toArray(new String[0]); adaptertwo = new ArrayAdapter<String>(this, R.layout.listview_simpleitem, mStrings); listview.setAdapter(adaptertwo); listview.setOnItemClickListener(new OnItemClickListener() { @SuppressWarnings("unchecked") @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // -----------------------?--------------- if (position == carset.getSize()) { Intent intent = new Intent(MainActivity.this, AddLicenseplateActivity.class); intent.putExtra("build", 1); startActivityForResult(intent, 3); } else { String carid = carset.getItem(position).getCar_id() + ""; HashMap<String, String> idtakjson = new UserEntity().getIdTaken(MainActivity.this); idtakjson.put("car_id", carid); new HttpTask(homeCallback, MyURL.CHANGECAR, MainActivity.this).execute(idtakjson); } // getPopupWindow(); } }); popupview = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); // popupview.setBackgroundDrawable(getResources().getDrawable(R.drawable.popupgray)); popupview.setAnimationStyle(android.R.style.Animation_InputMethod); // ?? popupview.setOutsideTouchable(true); popupview.setFocusable(true); popupview.setTouchable(true); // ???? popupview.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); view.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (popupview != null && popupview.isShowing()) { tv_changecar.setVisibility(View.VISIBLE); popupview.dismiss(); popupview = null; } return false; } }); }
From source file:android.support.v7ox.app.AppCompatDelegateImplV7.java
@Override ActionMode startSupportActionModeFromWindow(ActionMode.Callback callback) { endOnGoingFadeAnimation();/*from w w w . j a v a 2 s.c o m*/ if (mActionMode != null) { mActionMode.finish(); } final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapperV7(callback); ActionMode mode = null; if (mAppCompatCallback != null && !isDestroyed()) { try { mode = mAppCompatCallback.onWindowStartingSupportActionMode(wrappedCallback); } catch (AbstractMethodError ame) { // Older apps might not implement this callback method. } } if (mode != null) { mActionMode = mode; } else { if (mActionModeView == null) { if (mIsFloating) { // Use the action bar theme. final TypedValue outValue = new TypedValue(); final Resources.Theme baseTheme = mContext.getTheme(); baseTheme.resolveAttribute(R.attr.actionBarTheme_ox, outValue, true); final Context actionBarContext; if (outValue.resourceId != 0) { final Resources.Theme actionBarTheme = mContext.getResources().newTheme(); actionBarTheme.setTo(baseTheme); actionBarTheme.applyStyle(outValue.resourceId, true); actionBarContext = new ContextThemeWrapper(mContext, 0); actionBarContext.getTheme().setTo(actionBarTheme); } else { actionBarContext = mContext; } mActionModeView = new ActionBarContextView(actionBarContext); mActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle_ox); PopupWindowCompat.setWindowLayoutType(mActionModePopup, WindowManager.LayoutParams.TYPE_APPLICATION); mActionModePopup.setContentView(mActionModeView); mActionModePopup.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize_ox, outValue, true); final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics()); mActionModeView.setContentHeight(height); mActionModePopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); mShowActionModePopup = new Runnable() { public void run() { mActionModePopup.showAtLocation(mActionModeView, Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0); endOnGoingFadeAnimation(); ViewCompat.setAlpha(mActionModeView, 0f); mFadeAnim = ViewCompat.animate(mActionModeView).alpha(1f); mFadeAnim.setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { ViewCompat.setAlpha(mActionModeView, 1f); mFadeAnim.setListener(null); mFadeAnim = null; } @Override public void onAnimationStart(View view) { mActionModeView.setVisibility(View.VISIBLE); } }); } }; } else { ViewStubCompat stub = (ViewStubCompat) mSubDecor.findViewById(R.id.action_mode_bar_stub); if (stub != null) { // Set the layout inflater so that it is inflated with the action bar's context stub.setLayoutInflater(LayoutInflater.from(getActionBarThemedContext())); mActionModeView = (ActionBarContextView) stub.inflate(); } } } if (mActionModeView != null) { endOnGoingFadeAnimation(); mActionModeView.killMode(); mode = new StandaloneActionMode(mActionModeView.getContext(), mActionModeView, wrappedCallback, mActionModePopup == null); if (callback.onCreateActionMode(mode, mode.getMenu())) { mode.invalidate(); mActionModeView.initForMode(mode); mActionMode = mode; ViewCompat.setAlpha(mActionModeView, 0f); mFadeAnim = ViewCompat.animate(mActionModeView).alpha(1f); mFadeAnim.setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { ViewCompat.setAlpha(mActionModeView, 1f); mFadeAnim.setListener(null); mFadeAnim = null; } @Override public void onAnimationStart(View view) { mActionModeView.setVisibility(View.VISIBLE); mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); if (mActionModeView.getParent() != null) { ViewCompat.requestApplyInsets((View) mActionModeView.getParent()); } } }); if (mActionModePopup != null) { mWindow.getDecorView().post(mShowActionModePopup); } } else { mActionMode = null; } } } if (mActionMode != null && mAppCompatCallback != null) { mAppCompatCallback.onSupportActionModeStarted(mActionMode); } return mActionMode; }
From source file:com.cpic.taylor.logistics.activity.HomeActivity.java
/** * // ww w. ja v a 2 s .c o m * @param v * @param type1 * @param type2 * @param isUser */ private void showPopupWindow(View v, final int type1, final int type2, final boolean isUser) { View view = View.inflate(HomeActivity.this, R.layout.popupwindow_1, null); tvCamera = (TextView) view.findViewById(R.id.btn_camera); tvPhoto = (TextView) view.findViewById(R.id.btn_photo); tvBack = (TextView) view.findViewById(R.id.btn_back); tvCamera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFromCamera(type1, isUser); pw.dismiss(); } }); tvPhoto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFromPhoto(type2); pw.dismiss(); } }); tvBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pw.dismiss(); } }); pw = new PopupWindow(view, screenWidth * 99 / 100, LinearLayout.LayoutParams.WRAP_CONTENT); pw.setFocusable(true); WindowManager.LayoutParams params = HomeActivity.this.getWindow().getAttributes(); HomeActivity.this.getWindow().setAttributes(params); pw.setBackgroundDrawable(new ColorDrawable()); pw.setOutsideTouchable(true); pw.setAnimationStyle(R.style.pw_anim_style); pw.showAtLocation(v, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); pw.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { WindowManager.LayoutParams params = HomeActivity.this.getWindow().getAttributes(); params.alpha = 1f; HomeActivity.this.getWindow().setAttributes(params); } }); }
From source file:org.onebusaway.android.ui.ArrivalsListHeader.java
/** * Sets the popup for the status/* w w w. j av a 2 s.c om*/ * * @param index 0 if this is for the top ETA row, 1 if it is for the second * @param color color resource id to use for the popup background * @param statusText text to show in the status popup * @return a new PopupWindow initialized based on the provided parameters */ private PopupWindow setupPopup(final int index, int color, String statusText) { LayoutInflater inflater = LayoutInflater.from(mContext); TextView statusView = (TextView) inflater.inflate(R.layout.arrivals_list_tv_template_style_b_status_large, null); statusView.setBackgroundResource(R.drawable.round_corners_style_b_status); GradientDrawable d = (GradientDrawable) statusView.getBackground(); if (color != R.color.stop_info_ontime) { // Show early/late color d.setColor(mResources.getColor(color)); } else { // For on-time, use header default color d.setColor(mResources.getColor(R.color.theme_primary)); } d.setStroke(UIUtils.dpToPixels(mContext, 1), mResources.getColor(R.color.header_text_color)); int pSides = UIUtils.dpToPixels(mContext, 5); int pTopBottom = UIUtils.dpToPixels(mContext, 2); statusView.setPadding(pSides, pTopBottom, pSides, pTopBottom); statusView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); statusView.measure(TextView.MeasureSpec.UNSPECIFIED, TextView.MeasureSpec.UNSPECIFIED); statusView.setText(statusText); PopupWindow p = new PopupWindow(statusView, statusView.getWidth(), statusView.getHeight()); p.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); p.setBackgroundDrawable(new ColorDrawable(mResources.getColor(android.R.color.transparent))); p.setOutsideTouchable(true); p.setTouchInterceptor(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { boolean touchInView; if (index == 0) { touchInView = UIUtils.isTouchInView(mEtaAndMin1, event); } else { touchInView = UIUtils.isTouchInView(mEtaAndMin2, event); } return touchInView; } }); return p; }
From source file:com.fullteem.yueba.app.ui.ChatActivity.java
/** * window// ww w . j a v a2s . c om */ private void windowShow() { if (popupWindow == null) { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); menuView = layoutInflater.inflate(R.layout.popwindow_msgmenu, null); listviewMsgMenus = (ListView) menuView.findViewById(R.id.listviewMsgPop); mma = new MessageMenuAdapter(this, menuTexts); listviewMsgMenus.setAdapter(mma); // PopuWidow popupWindow = new PopupWindow(menuView, 300, 500); } // ? popupWindow.setFocusable(true); // ? popupWindow.setOutsideTouchable(true); // Back??? popupWindow.setBackgroundDrawable(new BitmapDrawable()); WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); // ?:??-PopupWindow? int xPos = windowManager.getDefaultDisplay().getWidth() / 2 - popupWindow.getWidth() / 2; Log.i("coder", "windowManager.getDefaultDisplay().getWidth()/2:" + windowManager.getDefaultDisplay().getWidth() / 2); // Log.i("coder", "popupWindow.getWidth()/2:" + popupWindow.getWidth() / 2); Log.i("coder", "xPos:" + xPos); popupWindow.showAsDropDown(viewBtnMore, xPos, 0); listviewMsgMenus.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { if (popupWindow != null) { popupWindow.dismiss(); } // if (menuTexts[position].equals("")) { String strName = getString(R.string.add_firend); String msg = String.format(strName, userNickName); popMenu = new CommonPopWindow(ChatActivity.this, msg, new OnClickListener() { @Override public void onClick(View v) { addContact(); addFriendPop.dismiss(); } }, new OnClickListener() { @Override public void onClick(View v) { addFriendPop.dismiss(); } }); // ? popMenu.setIsEditText(false); // popMenu.preperShow(); addFriendPop = popMenu.getMenu(); addFriendPop.setOutsideTouchable(true); if (addFriendPop == null) { return; } if (addFriendPop.isShowing()) { addFriendPop.dismiss(); return; } addFriendPop.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0); } else if (menuTexts[position].equals("?")) { } // ? else if (menuTexts[position].equals("")) { // try { // EMContactManager.getInstance().deleteContact( // toChatUsername); // } catch (EaseMobException e) { // showToast(""); // } deleteFriends(); } else if (menuTexts[position].equals("?")) {// bill Intent intentDatePublish = new Intent(ChatActivity.this, DatePublishActivity.class); // TODO ????id,????????idname DBFriendListDao friendListDao = new DBFriendListDao(ChatActivity.this); UserCommonModel um = friendListDao.getContacter(toChatUsername); if (um == null) return; UmengUtil.onEvent(ChatActivity.this, "friend_chat_access_post_date_button_hits"); LogUtil.printUmengLog("friend_chat_access_post_date_button_hits"); intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_ID, Integer.valueOf(TextUtils.isEmpty(um.getUserId()) ? "0" : um.getUserId())); // userIdint intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_NAME, um.getUserName()); // String intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_MOBILE, um.getUserMobile()); intentDatePublish.putExtra(GlobleConstant.DATE_FAVORITE_URL, um.getUserLogoUrl()); intentDatePublish.putExtra("isExist", true); startActivity(intentDatePublish); } else if (menuTexts[position].equals("")) { HttpRequest.getInstance(ChatActivity.this).getOutGroup(appContext.getUserInfo().getUserMobile(), toChatUsername, new CustomAsyncResponehandler() { @Override public void onSuccess(ResponeModel baseModel) { if (baseModel != null && baseModel.isStatus()) { showToast("?"); finish(); return; } showToast(getString(R.string.hint_operationError)); } @Override public void onFailure(Throwable error, String content) { showToast(getString(R.string.hint_operationError)); } }); } } }); }
From source file:org.videolan.vlc.gui.VLCMainActivity.java
private void popupStreamingList(final MultiRoom mRoom, final ArrayList<String> roomList) { final View v = getLayoutInflater().inflate(R.layout.streamingroom_list, null, false); int h = getWindowManager().getDefaultDisplay().getHeight(); int w = getWindowManager().getDefaultDisplay().getWidth(); popRoomList = new PopupWindow(v, w - 10, (int) (((2.8) * h) / 4)); popRoomList.setAnimationStyle(R.style.MyDialogStyleBottom); popRoomList.setFocusable(true);/*from w w w.j a v a 2 s .co m*/ popRoomList.setBackgroundDrawable(new BitmapDrawable()); new Handler().postDelayed(new Runnable() { @Override public void run() { popRoomList.showAtLocation(v, Gravity.BOTTOM, 0, 0); } }, 500L); ArrayAdapter<String> roomAdapter = new ArrayAdapter<String>(this, R.layout.streamingroom_list_background, R.id.text1, roomList); ListView roomlistView = (ListView) v.findViewById(R.id.roomlist); roomlistView.setItemsCanFocus(true); // roomlistView.setCacheColorHint(Color.TRANSPARENT); roomlistView.setAdapter(roomAdapter); roomlistView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { if (p != null) { /** rejoin the chat Room*/ MultiUserChat muc = new MultiUserChat(connection, roomList.get(position) + "@" + serviceName); try { //TODO 4: require password >>>>>>>>>>>>>>>>>>>>. muc.join(connection.getUser(), p); Log.i("VLCMainActivity--p", p); Log.i("VLCMainActivity--rejoin user", connection.getUser()); } catch (XMPPException e) { //e.printStackTrace(); } // set new chat room if (mRoom.getChatRoom() == null) { mRoom.setChatRoom(roomList.get(position)); Log.i("VLCMainActivity--get room", "null"); } /** request video streaming*/ AudioServiceController audioServiceController = AudioServiceController.getInstance(); // use audio as default player... String mAddress = mSettings.getString("key_server_address", null); String mPort = mSettings.getString("key_server_port", null); String streaminglink = "rtsp://" + mAddress + ":" + mPort + "/" + roomList.get(position) + ".sdp"; Log.i("VLCMainActivity--request streaminglink", streaminglink); audioServiceController.load(streaminglink, false); popRoomList.dismiss(); } else { popRoomList.dismiss(); Toast.makeText(getApplicationContext(), "Can't join because of No password", Toast.LENGTH_SHORT) .show(); } } }); }
From source file:ab.util.AbDialogUtil.java
/** * popupwindow//from w w w. j a va 2 s . c o m */ public static PopupWindow showPopWindow(Context context, View targetView, View contentView, Integer width) { PopupWindow popupWindow = null; popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); if (width != null) { popupWindow.setWidth(width); } popupWindow.setOutsideTouchable(true); popupWindow.showAsDropDown(targetView); return popupWindow; }
From source file:ab.util.AbDialogUtil.java
/** * popupwindow/*from w w w . ja va2 s.c om*/ */ public static PopupWindow showPopWindow2(Context context, View targetView, View contentView, Integer width) { PopupWindow popupWindow = null; popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); if (width != null) { popupWindow.setWidth(width); } popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0); return popupWindow; }