List of usage examples for android.widget PopupWindow showAtLocation
@UnsupportedAppUsage public void showAtLocation(IBinder token, int gravity, int x, int y)
From source file:com.vanisty.ui.MenuActivity.java
private void showPopup(final Activity context, Point p) { int popupWidth = 200; int popupHeight = 150; // Inflate the popup_layout.xml LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.popup); LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_layout, viewGroup); // Creating the PopupWindow final PopupWindow popup = new PopupWindow(context); popup.setContentView(layout);//w ww .ja v a 2 s. com popup.setWidth(popupWidth); popup.setHeight(popupHeight); popup.setFocusable(true); // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. int OFFSET_X = 30; int OFFSET_Y = 30; // Clear the default translucent background popup.setBackgroundDrawable(new BitmapDrawable()); // Displaying the popup at the specified location, + offsets. popup.showAtLocation(layout, Gravity.NO_GRAVITY, p.x + OFFSET_X, p.y + OFFSET_Y); // Getting a reference to Close button, and close the popup when clicked. Button close = (Button) layout.findViewById(R.id.close); close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popup.dismiss(); } }); }
From source file:com.example.angel.parkpanda.MainActivity.java
@Override public boolean onNavigationItemSelected(MenuItem item) { int id = item.getItemId(); showhideFootWindow(0);/* w ww. j a v a 2 s . c o m*/ if (id == R.id.nav_menu_findparking) { Intent intent = new Intent(getApplicationContext(), Find_Park.class); startActivityForResult(intent, 2);// Activity is started with requestCode 2 // finish(); } if (id == R.id.nav_menu_account) { initViewSetting(false); if (LOGININFO.flag == 10) { Fragment fragment = new my_account(); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction FT = fragmentManager.beginTransaction(); FT.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left); FT.replace(R.id.flContent, fragment).commit(); } else { Fragment fragment = new log_in(); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction FT = fragmentManager.beginTransaction(); FT.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left); FT.replace(R.id.flContent, fragment).commit(); } } if (id == R.id.nav_menu_help) { int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion > 21) { showhideFootWindow(0); initViewSetting(true); LayoutInflater inflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.ly_my_help, null); layout.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popupanim)); PopupWindow optionspu = new PopupWindow(layout, DrawerLayout.LayoutParams.WRAP_CONTENT, DrawerLayout.LayoutParams.WRAP_CONTENT); optionspu.setFocusable(true); optionspu.showAtLocation(layout, Gravity.CENTER, 0, 0); optionspu.update(0, 0, DrawerLayout.LayoutParams.WRAP_CONTENT, DrawerLayout.LayoutParams.WRAP_CONTENT); optionspu.setAnimationStyle(R.anim.popupanim); } else { // initViewSetting(false); /* Fragment fragment = new help_dialog(); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction FT = fragmentManager.beginTransaction(); FT.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left); FT.replace(R.id.flContent, fragment).commit();*/ LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View popupView = layoutInflater.inflate(R.layout.fragment_help_dialog, null); final PopupWindow optionspu = new PopupWindow(popupView, DrawerLayout.LayoutParams.WRAP_CONTENT, DrawerLayout.LayoutParams.WRAP_CONTENT); optionspu.setFocusable(true); optionspu.showAtLocation(popupView, Gravity.CENTER, 0, 0); Button btnDismiss = (Button) popupView.findViewById(R.id.btn_help_close); btnDismiss.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { // Toast.makeText(getApplicationContext(), "dsdsa", Toast.LENGTH_SHORT).show(); optionspu.dismiss(); plotMarkers(mMyMarkersArray); initViewSetting(true); } }); } } drawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.duy.pascal.ui.debug.activities.DebugActivity.java
@WorkerThread private void showPopupAt(final LineNumber lineNumber, final String msg) { mHandler.post(new Runnable() { @Override//from w w w . j a v a 2 s. c om public void run() { if (isFinishing()) return; //get relative position of expression at edittext Point position = mCodeView.getDebugPosition(lineNumber.getLine(), lineNumber.getColumn(), Gravity.TOP); DLog.d(TAG, "generate: " + position); dismissPopup(); //create new popup PopupWindow window = new PopupWindow(DebugActivity.this); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View container = inflater.inflate(R.layout.popup_expr_result, null); container.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); int windowHeight = container.getMeasuredHeight(); int windowWidth = container.getMeasuredWidth(); window.setContentView(container); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); window.setTouchable(true); window.setSplitTouchEnabled(true); window.setOutsideTouchable(true); window.showAtLocation(mCodeView, Gravity.NO_GRAVITY, position.x - windowWidth / 3, position.y + toolbar.getHeight() - windowHeight); TextView txtResult = container.findViewById(R.id.txt_result); txtResult.setText(msg); AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.5f); alphaAnimation.setDuration(1000); alphaAnimation.setRepeatMode(Animation.REVERSE); alphaAnimation.setRepeatCount(Animation.INFINITE); txtResult.startAnimation(alphaAnimation); DebugActivity.this.mPopupWindow = window; } }); }
From source file:com.survivingwithandroid.pegboard.DreamPinsActivity.java
@Override public void onSaveSelected() { closeMenu();/*from w w w.ja va 2s . co 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); } 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.survivingwithandroid.pegboard1.DreamPinsActivity.java
@Override public void onSaveSelected() { closeMenu();/* w w w . ja va 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); /////////////// } 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();/* ww w . jav a 2s .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.luke.lukef.lukeapp.fragments.MapViewFragment.java
/** * Handles showing the Calendar pop up, fetching the selected date, calling to fetch * submissions again//from w ww . j a v a2s .c om */ private void showCalendarPicker() { // Inflate the popup_layout.xml ConstraintLayout viewGroup = (ConstraintLayout) getMainActivity().findViewById(R.id.popup_calendar_root); LayoutInflater layoutInflater = (LayoutInflater) getMainActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = layoutInflater.inflate(R.layout.popup_calendar, viewGroup); // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. //or if popup is on edge display it to the left of the circle Display display = getMainActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(0, 0); display.getSize(size); int OFFSET_X = 25; int OFFSET_Y = 25; final DatePicker dP = (DatePicker) layout.findViewById(R.id.popup_calendar_datepicker); // Creating the PopupWindow final PopupWindow popup = new PopupWindow(getMainActivity()); popup.setAnimationStyle(android.R.style.Animation_Dialog); popup.setContentView(layout); popup.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); popup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); popup.setFocusable(true); //gets rid of default background popup.setBackgroundDrawable(new BitmapDrawable(getMainActivity().getResources(), (Bitmap) null)); //popup.setBackgroundDrawable(new BitmapDrawable(getMainActivity().getResources(), (Bitmap) nu)); // Displaying the popup at the specified location, + offsets. popup.showAtLocation(layout, Gravity.NO_GRAVITY, 200 + OFFSET_X, 300 + OFFSET_Y); Calendar minDate; minDate = Calendar.getInstance(); this.tempY = minDate.get(Calendar.YEAR); this.tempM = minDate.get(Calendar.MONTH); this.tempD = minDate.get(Calendar.DAY_OF_MONTH); dP.init(minDate.get(Calendar.YEAR), minDate.get(Calendar.MONTH), minDate.get(Calendar.DAY_OF_MONTH), new DatePicker.OnDateChangedListener() { @Override // Months start from 0, so January is month 0 public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { tempY = year; tempM = monthOfYear; tempD = dayOfMonth; Log.e(TAG, "onDateChanged: selected " + tempD + " " + tempM + " " + tempY); } }); ImageButton okButton = (ImageButton) layout.findViewById(R.id.popup_calendar_accept); ImageButton cancelButton = (ImageButton) layout.findViewById(R.id.popup_calendar_cancel); okButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar calendar = Calendar.getInstance(); calendar.set(tempY, tempM, tempD, 1, 0); Log.e(TAG, "onClick: calendar time in ms " + calendar.getTimeInMillis()); // clear items from clustermanager and submissionMarkerList, as all new submissions // need to be fetched based on the selected date clusterManager.clearItems(); submissionMarkerIdList.clear(); addAdminMarkersToMap(); setMinDateInMs(calendar.getTimeInMillis()); popup.dismiss(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { setMinDateInMs(0); popup.dismiss(); } }); }
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 w w . java 2 s. com*/ 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: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 ww w. java 2s.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.quwu.xinwo.release.Release_Activity.java
/** * /*w w w . j a v a 2 s. c o m*/ * PopupWindow * * */ private void showPopupWindow(View view, final int i) { // View contentView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.release_pop, null); final PopupWindow popupWindow = new PopupWindow(contentView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true); popupWindow.setOnDismissListener(new OnDismissListener() { public void onDismiss() { releaseLin.setAlpha(1f); } }); popupWindow.setTouchable(true); popupWindow.setTouchInterceptor(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return false; // true?touch // ? PopupWindowonTouchEvent?dismiss } }); // ?PopupWindowBackdismiss // APIbug popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_launcher)); // ???show int[] location = new int[2]; view.getLocationOnScreen(location); popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, location[0] + view.getWidth(), location[1] - 150); // TextView year = (TextView) contentView.findViewById(R.id.release_pop_yearText); year.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { handler.sendMessage(handler.obtainMessage(i, "/")); popupWindow.dismiss(); } }); TextView month = (TextView) contentView.findViewById(R.id.release_pop_monthText); month.setOnClickListener(new OnClickListener() { public void onClick(View v) { handler.sendMessage(handler.obtainMessage(i, "/")); popupWindow.dismiss(); } }); TextView day = (TextView) contentView.findViewById(R.id.release_pop_dayText); day.setOnClickListener(new OnClickListener() { public void onClick(View v) { handler.sendMessage(handler.obtainMessage(i, "/")); popupWindow.dismiss(); } }); }