List of usage examples for android.widget PopupWindow PopupWindow
public PopupWindow(View contentView, int width, int height, boolean focusable)
Create a new popup window which can display the contentView.
From source file:fr.univsavoie.ltp.client.map.Popup.java
public final void popupGetStatus(JSONArray pStatusesArray) { DisplayMetrics dm = new DisplayMetrics(); this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm); //final int height = dm.heightPixels; final int width = dm.widthPixels; final int height = dm.heightPixels; int popupWidth = (int) (width * 0.75); int popupHeight = height; // Inflate the popup_layout.xml ScrollView viewGroup = (ScrollView) this.activity.findViewById(R.id.popupGetStatus); LayoutInflater layoutInflater = (LayoutInflater) this.activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = layoutInflater.inflate(R.layout.popup_get_status, viewGroup); layout.setBackgroundResource(R.drawable.popup_gradient); // Crer le PopupWindow final PopupWindow popupPublishStatus = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true); popupPublishStatus.setBackgroundDrawable(new BitmapDrawable()); popupPublishStatus.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() { popupPublishStatus.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y); }/* w ww .j a va 2 s .c om*/ }); /* * Evenements composants du PopupWindow */ // Find the ListView resource. ListView mainListView = (ListView) layout.findViewById(R.id.listViewStatus); ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); SimpleAdapter adapter = new SimpleAdapter(this.activity, list, R.layout.custom_row_view, new String[] { "content", "lat", "lon" }, new int[] { R.id.text1, R.id.text2, R.id.text3 }); try { // Appel REST pour recuperer les status de l'utilisateur connect //Session session = new Session(this.activity); //session.parseJSONUrl("https://jibiki.univ-savoie.fr/ltpdev/rest.php/api/1/statuses", "STATUSES", "GET"); // Parser la liste des amis dans le OverlayItem ArrayList HashMap<String, String> temp; for (int i = 0; (i < 6); i++) { // Obtenir le status JSONObject status = pStatusesArray.getJSONObject(i); temp = new HashMap<String, String>(); temp.put("content", status.getString("content")); temp.put("lat", String.valueOf(status.getDouble("lat"))); temp.put("lon", String.valueOf(status.getDouble("lon"))); list.add(temp); } } catch (JSONException jex) { Log.e("Catch", "popupGetStatus / JSONException : " + jex.getStackTrace()); } catch (Exception ex) { Log.e("Catch", "popupGetStatus / Exception : " + ex.getLocalizedMessage()); } mainListView.setAdapter(adapter); }
From source file:com.zia.freshdocs.widget.adapter.CMISAdapter.java
/** * Display file information/*from www .ja v a 2 s . c o m*/ * * @param context */ public void showFileInfo(Context context, int position, boolean isFile) { final NodeRef ref = getItem(position); try { //We need to get the instance of the LayoutInflater, use the context of this activity LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //Inflate the view from a predefined XML layout View layout = inflater.inflate(R.layout.file_info_dialog, null, false); // create a WRAP_CONTENT PopupWindow PopupWindow mPopUp = new PopupWindow(layout, WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, true); mPopUp.setBackgroundDrawable(new BitmapDrawable()); mPopUp.setOutsideTouchable(true); // display the popup in the center mPopUp.showAtLocation(layout, Gravity.CENTER, 0, 0); TextView title = (TextView) layout.findViewById(R.id.dialog_title); if (isFile) title.setText(context.getString(R.string.str_file_information)); else title.setText(context.getString(R.string.str_folder_information)); UITableView tableView = (UITableView) layout.findViewById(R.id.tableView); ViewItem viewItem; if (ref.getName() != null) { viewItem = Utils.createCustomView(context, context.getString(R.string.str_name), ref.getName()); tableView.addViewItem(viewItem); } if (ref.getCreateBy() != null) { viewItem = Utils.createCustomView(context, context.getString(R.string.str_created_by), ref.getCreateBy()); tableView.addViewItem(viewItem); } if (ref.getLastModificationDate() != null) { viewItem = Utils.createCustomView(context, context.getString(R.string.str_last_modification_date), ref.getLastModificationDate()); tableView.addViewItem(viewItem); } if (ref.getLastModifiedBy() != null) { viewItem = Utils.createCustomView(context, context.getString(R.string.str_last_modified_by), ref.getLastModifiedBy()); tableView.addViewItem(viewItem); } if (ref.getContent() != null) { viewItem = Utils.createCustomView(context, context.getString(R.string.str_content), ref.getContent()); tableView.addViewItem(viewItem); } if (ref.getContentType() != null) { viewItem = Utils.createCustomView(context, context.getString(R.string.str_content_type), ref.getContentType()); tableView.addViewItem(viewItem); } if (ref.getObjectId() != null) { viewItem = Utils.createCustomView(context, context.getString(R.string.str_object_id), ref.getObjectId()); tableView.addViewItem(viewItem); } if (ref.getParentId() != null) { viewItem = Utils.createCustomView(context, context.getString(R.string.str_parent_id), ref.getParentId()); tableView.addViewItem(viewItem); } if (ref.getVersion() != null) { viewItem = Utils.createCustomView(context, context.getString(R.string.str_version), ref.getVersion()); tableView.addViewItem(viewItem); } tableView.commit(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.bilibili.boxing_impl.ui.BoxingViewFragment.java
public void setTitleTxt(TextView titleTxt) { mTitleTxt = titleTxt;// w w w .j a v a 2 s . c o m mTitleTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mAlbumPopWindow == null) { int height = WindowManagerHelper.getScreenHeight(v.getContext()) - (WindowManagerHelper.getToolbarHeight(v.getContext()) + WindowManagerHelper.getStatusBarHeight(v.getContext())); View windowView = createWindowView(); mAlbumPopWindow = new PopupWindow(windowView, ViewGroup.LayoutParams.MATCH_PARENT, height, true); mAlbumPopWindow.setAnimationStyle(R.style.PopupAnimation); mAlbumPopWindow.setOutsideTouchable(true); mAlbumPopWindow.setBackgroundDrawable( new ColorDrawable(ContextCompat.getColor(v.getContext(), R.color.colorPrimaryAlpha))); mAlbumPopWindow.setContentView(windowView); } mAlbumPopWindow.showAsDropDown(v, 0, 0); } @NonNull private View createWindowView() { View view = LayoutInflater.from(getActivity()).inflate(R.layout.layout_album, null); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.album_recycleview); recyclerView.setLayoutManager( new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false)); recyclerView.addItemDecoration(new SpacesItemDecoration(2, 1)); View albumShadowLayout = view.findViewById(R.id.album_shadow); albumShadowLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismissAlbumWindow(); } }); mAlbumWindowAdapter.setAlbumOnClickListener(new OnAlbumItemOnClickListener()); recyclerView.setAdapter(mAlbumWindowAdapter); return view; } }); }
From source file:com.watch.customer.ui.ShopListActivity.java
@SuppressWarnings("deprecation") private void showAreaPop(int width, int height) { layout = (LinearLayout) LayoutInflater.from(ShopListActivity.this).inflate(R.layout.popup_area, null); area_grid = (GridView) layout.findViewById(R.id.area_grid); area_grid.setOnItemClickListener(this); mAreaAdapter = new AreaAdapter(); area_grid.setAdapter(mAreaAdapter);//ww w. j a v a 2 s.c o m mPopWin = new PopupWindow(layout, width, LayoutParams.WRAP_CONTENT, true); View area_loc = (LinearLayout) layout.findViewById(R.id.area_loc); area_loc.setOnClickListener(this); mPopWin.setBackgroundDrawable(new BitmapDrawable()); mPopWin.showAsDropDown(findViewById(R.id.head), 0, 0); mPopWin.update(); }
From source file:net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.java
/** * Constructs a new swipe-to-dismiss touch listener for the given list view. * * @param listView The list view whose items should be dismissable. * @param callbacks The callback to trigger when the user has indicated that she would like to * dismiss one or more list items. *//*from w ww . j a v a 2 s . c om*/ public SwipeDismissListViewTouchListener(ListView listView, DismissCallbacks callbacks) { ViewConfiguration vc = ViewConfiguration.get(listView.getContext()); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = listView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime); mListView = listView; mCallbacks = callbacks; // Initialize undo popup LayoutInflater inflater = (LayoutInflater) listView.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View undoView = inflater.inflate(R.layout.undo_popup, null); mUndoButton = (Button) undoView.findViewById(R.id.undo); mUndoButton.setOnClickListener(new UndoClickListener()); mUndoButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // If the user touches the screen invalidate the current running delay by incrementing // the valid message id. So this delay won't hide the undo popup anymore mValidDelayedMsgId++; return false; } }); mUndoPopupTextView = (TextView) undoView.findViewById(R.id.text); mUndoPopup = new PopupWindow(undoView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, false); mUndoPopup.setAnimationStyle(R.style.Animations_PopUpMenu_Fade); mScreenDensity = listView.getResources().getDisplayMetrics().density; // END initialize undo popup mListView.setOnTouchListener(this); // Setting this scroll listener is required to ensure that during ListView scrolling, // we don't look for swipes. mListView.setOnScrollListener(makeScrollListener()); }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
private void viewAttechmentPopup(View v) { PopupWindow attechmentOptionsPopup = null; View menu_layout = getLayoutInflater().inflate(R.layout.attechmentlayout, null); menu_layout.setVisibility(View.VISIBLE); LinearLayout linLayGallery = (LinearLayout) menu_layout.findViewById(R.id.linLayGallery); LinearLayout linLayPhoto = (LinearLayout) menu_layout.findViewById(R.id.linLayPhoto); LinearLayout linLayVideo = (LinearLayout) menu_layout.findViewById(R.id.linLayVideo); LinearLayout linLayAudio = (LinearLayout) menu_layout.findViewById(R.id.linLayAudio); LinearLayout linLayLocation = (LinearLayout) menu_layout.findViewById(R.id.linLayLocation); LinearLayout linLayContact = (LinearLayout) menu_layout.findViewById(R.id.linLayContact); linLayGallery.setOnClickListener(new View.OnClickListener() { @Override// w w w . ja v a2 s. c o m public void onClick(View arg0) { // TODO Auto-generated method stub // Toast.makeText(MessageActivity.this,"coming soon",Toast.LENGTH_SHORT).show(); selectWindow.dismiss(); cameraImage(); } }); linLayPhoto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectWindow.dismiss(); showFileChooser(); } }); linLayVideo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectWindow.dismiss(); showVideoFileChooser(); } }); linLayAudio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectWindow.dismiss(); showAudioFileChooser(); } }); linLayLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectWindow.dismiss(); sendLocationMessage(); } }); linLayContact.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectWindow.dismiss(); onBrowseForNumbersButtonClicked(); } }); attechmentOptionsPopup = new PopupWindow(menu_layout, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); selectWindow = attechmentOptionsPopup; commonPopupWindowDisplay(attechmentOptionsPopup, v, 0, 15); }
From source file:com.zhihuigu.sosoOffice.RegisterThirdActivity.java
/** * PopupWindow//from w w w. j ava 2s . c o m */ private void initPopuWindow() { // PopupWindow View loginwindow = (View) this.getLayoutInflater().inflate(R.layout.dialog_share, null); shareBtn1 = (Button) loginwindow.findViewById(R.id.eshareBtn1); shareBtn2 = (Button) loginwindow.findViewById(R.id.eshareBtn2); shareBtn3 = (Button) loginwindow.findViewById(R.id.eshareBtn3); cancleBtn = (Button) loginwindow.findViewById(R.id.eshareCancleBtn); shareBtn1.setOnClickListener(this); shareBtn2.setOnClickListener(this); shareBtn3.setOnClickListener(this); cancleBtn.setOnClickListener(this); parent = (LinearLayout) findViewById(R.id.parent); selectPopupWindow = new PopupWindow(loginwindow, parent.getWidth(), LayoutParams.WRAP_CONTENT, true); // PopupWindowBackPopupWindow // selectPopupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_border)); selectPopupWindow.setOutsideTouchable(true); selectPopupWindow.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss() { // TODO Auto-generated method stub dismiss(); } }); }
From source file:pro.dbro.iburn_2012.OpenStreetMapFragment.java
public void setPoiLayer() { poiOverlay = new ItemizedOverlayWithFocus<OverlayItem>(generateOverlayItems(), new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() { @Override// w w w . j a v a 2 s . co m public boolean onItemSingleTapUp(final int index, final OverlayItem item) { if (mapOverlayShowing == false) { activePoi = index; LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(getActivity().LAYOUT_INFLATER_SERVICE); View popup = layoutInflater.inflate(R.layout.map_item_popup, null); Log.d("itemClick", item.getTitle() + " " + item.mDescription); ((TextView) popup.findViewById(R.id.popup_title)).setText(item.getTitle()); popup.setTag(R.id.list_item_related_model, item.mDescription); popup.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pw.dismiss(); //FragmentTabsPager.mViewPager.setCurrentItem(2); String camp_id = v.getTag(R.id.list_item_related_model).toString(); CampFragment.CursorLoaderListFragment .showCampPopup(OpenStreetMapFragment.mapView, camp_id); } }); pw = new PopupWindow(popup, LayoutParams.MATCH_PARENT, 100, true); pw.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss() { mapOverlayShowing = false; poiOverlay.getItem(activePoi) .setMarker(getResources().getDrawable(R.drawable.red_pin)); } }); item.setMarker(getResources().getDrawable(R.drawable.blue_pin)); pw.setFocusable(true); //pw.setOutsideTouchable(true); pw.setBackgroundDrawable(new BitmapDrawable()); //pw. //pw.showAsDropDown(OpenStreetMapFragment.container); pw.showAtLocation(OpenStreetMapFragment.mapView, Gravity.BOTTOM, 0, 0); mapOverlayShowing = true; } return false; // We 'handled' this event. } @Override public boolean onItemLongPress(final int index, final OverlayItem item) { return false; } }, mResourceProxy); }
From source file:dong.lan.tuyi.activity.MainActivity.java
private void guidePop() { View view = LayoutInflater.from(this).inflate(R.layout.guide_pop1, null); view.findViewById(R.id.guide_1).setOnClickListener(new View.OnClickListener() { @Override//from w ww . java 2 s . c o m public void onClick(View v) { p.dismiss(); Config.setGuide1(getBaseContext(), true); } }); p = new PopupWindow(view, ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT, true); p.showAtLocation(findViewById(R.id.mainLayout), Gravity.CENTER, 0, 0); }
From source file:com.mci.firstidol.activity.MainActivity.java
/** * ?//from w w w.ja v a2 s. com * * @param starList */ public void initStarList(final List<Object> starList) { starAdapter = new MyStarAdapter(context, starList, null); star_gridView.setAdapter(starAdapter); star_gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { Constant.starModel = (StarModel) starList.get(position); PreferencesUtils.setStarId(context, Constant.starModel.starId); updateStarNotice(); if (starPopWindows != null && starPopWindows.isShowing()) { starPopWindows.dismiss(); isMasterRequest(); } } }); starPopWindows = new PopupWindow(view_myStar, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, true); starPopWindows.setOutsideTouchable(true); starPopWindows.setBackgroundDrawable(new BitmapDrawable()); starPopWindows.setAnimationStyle(R.style.mypopwindow_anim_style); starPopWindows.showAsDropDown(titleTextView); }