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:com.morphoss.jumble.frontend.CategoryScreenActivity.java
/** * This method creates a popup window when a level is unlocked *//*from w ww . ja va2 s. co m*/ public void PopupWindowLevel() { try { LayoutInflater inflater = (LayoutInflater) CategoryScreenActivity.this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.popup_level, (ViewGroup) findViewById(R.id.popup_element)); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); pwindowLevel = new PopupWindow(layout, metrics.widthPixels, metrics.heightPixels, true); pwindowLevel.showAtLocation(layout, Gravity.CENTER, 0, 0); btnClosePopupLevel = (ImageView) layout.findViewById(R.id.btn_close_popup); btnClosePopupLevel.setOnClickListener(cancel_popup_level); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.tutor.activity.SlidingActivity.java
private void showPopupWindow() { if (popupWindow == null) { final SearchWindow window = new SearchWindow(this, applicationData.getappCategories()); popupWindow = new PopupWindow(window, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, true); window.setCategoryListOnItemClickListener(new OnItemClickListener() { @Override/*from w ww.j av a 2 s. c om*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(SlidingActivity.this, SearchResultActivity.class); intent.putExtra("Flag", "Category"); intent.putExtra("CategoryId", applicationData.getappCategories().get(position).getid()); intent.putExtra("CategoryName", applicationData.getappCategories().get(position).getname()); SlidingActivity.this.startActivity(intent); } }); window.setOnHiddenClickListener(new OnClickListener() { @Override public void onClick(View v) { hidePopupWindow(); } }); window.setOnSearchListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(SlidingActivity.this, SearchResultActivity.class); intent.putExtra("Flag", "App"); intent.putExtra("SearchFilter", window.getsearchFilter()); startActivity(intent); } }); } popupWindow.setTouchable(true); popupWindow.setOutsideTouchable(false); popupWindow.setBackgroundDrawable( new BitmapDrawable(getResources(), Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888))); popupWindow.showAtLocation(findViewById(R.id.slidingMenu), Gravity.TOP, 0, 0); }
From source file:com.cybrosys.scientific.EventListener.java
@SuppressWarnings("deprecation") public void showcon() { LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); vwLayout = inflater.inflate(R.layout.firstone, (ViewGroup) ((Activity) ctx).findViewById(R.id.popup_element)); popmW1 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true); popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 30); popmW1.setBackgroundDrawable(new BitmapDrawable()); popmW1.setOutsideTouchable(true);// ww w .j a v a 2 s. co m imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.butcancelmain); imgbtnclose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW1.dismiss(); } }); btnuniversal = (Button) vwLayout.findViewById(R.id.butuniverse); btnuniversal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { universal(); } private void universal() { LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View vwLayout = inflater.inflate(R.layout.universe, (ViewGroup) ((Activity) ctx).findViewById(R.id.unive)); popmW2 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true); popmW2.setBackgroundDrawable(new BitmapDrawable()); popmW2.setOutsideTouchable(true); popmW1.setOutsideTouchable(true); popmW2.showAtLocation(vwLayout, Gravity.CENTER, 0, 30); btnseletone = (Button) vwLayout.findViewById(R.id.btnunione); btnseletone.setText( Html.fromHtml("Speed of Light in Vacuum<br/><small>299,792,458m.s<sup>-1</sup></small>")); btnseletone.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW2.dismiss(); popmW1.dismiss(); mHandler.insert("299792458"); } }); btnselettwo = (Button) vwLayout.findViewById(R.id.btnunitwo); btnselettwo.setText(Html.fromHtml( "Gravitational Constant<br/><small>6.67428*10<sup>-11</sup>m<sup>3</sup>.kg<sup>-1</sup>.s<sup>-2</sup></small>")); btnselettwo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW2.dismiss(); popmW1.dismiss(); mHandler.insert("6.67428e-11"); } }); btnseletthree = (Button) vwLayout.findViewById(R.id.btnunithree); btnseletthree.setText( Html.fromHtml("Planck Constant<br/><small>6.62606896*10<sup>-34</sup> inJ.s</small>")); btnseletthree.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW2.dismiss(); popmW1.dismiss(); mHandler.insert("6.62606896e-34"); } }); btnseletfour = (Button) vwLayout.findViewById(R.id.btnunifour); btnseletfour.setText(Html .fromHtml("Reduced Planck Constant<br/><small>1.054571628*10<sup>-34</sup> inJ.s</small>")); btnseletfour.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW2.dismiss(); popmW1.dismiss(); mHandler.insert("1.054571628e-34"); } }); imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.btncanceluni); imgbtnclose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW1.dismiss(); popmW2.dismiss(); } }); imgbtnback = (ImageButton) vwLayout.findViewById(R.id.btnbackuni); imgbtnback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW2.dismiss(); } }); } }); btnelectro = (Button) vwLayout.findViewById(R.id.btnelectro); btnelectro.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Electro(); } private void Electro() { LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View vwLayout = inflater.inflate(R.layout.electro, (ViewGroup) ((Activity) ctx).findViewById(R.id.elec)); popmW3 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true); popmW3.setBackgroundDrawable(new BitmapDrawable()); popmW3.setOutsideTouchable(true); popmW1.setOutsideTouchable(true); popmW3.showAtLocation(vwLayout, Gravity.CENTER, 0, 30); btnseletone = (Button) vwLayout.findViewById(R.id.butselectone); btnseletone.setText(Html.fromHtml( "Magnetic Constant<br/><small>1.256637067*10<sup>-6</sup> N.A<sup>-2</sup></small>")); btnseletone.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW3.dismiss(); popmW1.dismiss(); mHandler.insert("1.256637061e-6"); } }); btnselettwo = (Button) vwLayout.findViewById(R.id.butselecttwo); btnselettwo.setText(Html.fromHtml( "Electric Constant<br/><small>8.854187817*10<sup>-12</sup> F.m<sup>-1</sup></small>")); btnselettwo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW3.dismiss(); popmW1.dismiss(); mHandler.insert("8.854187817e-12"); } }); btnseletthree = (Button) vwLayout.findViewById(R.id.butselectthree); btnseletthree.setText( Html.fromHtml("Elementary Charge<br/><small>1.602176487*10<sup>-19</sup>c</small>")); btnseletthree.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW3.dismiss(); popmW1.dismiss(); mHandler.insert("1.602176487e-19"); } }); btnseletfour = (Button) vwLayout.findViewById(R.id.butselectfour); btnseletfour.setText( Html.fromHtml("Magnetic Flux Quantum<br/><small>2.067833667*10<sup>-15</sup>Wb</small>")); btnseletfour.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW3.dismiss(); popmW1.dismiss(); mHandler.insert("2.067833667e-15"); } }); btnseletfive = (Button) vwLayout.findViewById(R.id.butSelectfive); btnseletfive.setText( Html.fromHtml("Conductance Quantum<br/><small>7.7480917*10<sup>-5</sup>S</small>")); btnseletfive.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW3.dismiss(); popmW1.dismiss(); mHandler.insert("7.7480917e-5"); } }); imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.butcancelelectro); imgbtnclose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW1.dismiss(); popmW3.dismiss(); } }); imgbtnback = (ImageButton) vwLayout.findViewById(R.id.btnbackelectro); imgbtnback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW3.dismiss(); } }); } }); btnAtomic = (Button) vwLayout.findViewById(R.id.btnatomic); btnAtomic.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { atomic(); } private void atomic() { LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View vwLayout = inflater.inflate(R.layout.atomic, (ViewGroup) ((Activity) ctx).findViewById(R.id.atomic)); popmW4 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true); popmW4.setBackgroundDrawable(new BitmapDrawable()); popmW4.setOutsideTouchable(true); popmW1.setOutsideTouchable(true); popmW4.showAtLocation(vwLayout, Gravity.CENTER, 0, 30); btnseletone = (Button) vwLayout.findViewById(R.id.butatomone); btnseletone .setText(Html.fromHtml("Electron Mass<br/><small>9.10938215*10<sup>-13</sup>Kg</small>")); btnseletone.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW4.dismiss(); popmW1.dismiss(); mHandler.insert("9.10938215e-31"); } }); btnselettwo = (Button) vwLayout.findViewById(R.id.butatomtwo); btnselettwo.setText(Html.fromHtml("Proton Mass<br/><small>1.672621637*10<sup>-27</sup>Kg</small>")); btnselettwo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW4.dismiss(); popmW1.dismiss(); mHandler.insert("1.672621637e-27"); } }); btnseletthree = (Button) vwLayout.findViewById(R.id.butatomthree); btnseletthree.setText(Html.fromHtml("Fine Structure Constant<br/><small>0.007297353</small>")); btnseletthree.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW4.dismiss(); popmW1.dismiss(); mHandler.insert("0.007297353"); } }); btnseletfour = (Button) vwLayout.findViewById(R.id.atomfour); btnseletfour .setText(Html.fromHtml("Rydberg Constant<br/><small>10,973,731.57 m<sup>-1</sup></small>")); btnseletfour.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW4.dismiss(); popmW1.dismiss(); mHandler.insert("1097373157e-1"); } }); btnseletfive = (Button) vwLayout.findViewById(R.id.butatomfive); btnseletfive .setText(Html.fromHtml("Bohr Radious<br/><small>5.291772086*10<sup>-11</sup>m</small>")); btnseletfive.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW4.dismiss(); popmW1.dismiss(); mHandler.insert("5.291772086e-11"); } }); btnseletsix = (Button) vwLayout.findViewById(R.id.butatomsix); btnseletsix.setText(Html .fromHtml("Classical Electron Radius<br/><small>2.817940289*10<sup>-15</sup>m</small>")); btnseletsix.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW4.dismiss(); popmW1.dismiss(); mHandler.insert("2.817940289e-15"); } }); imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.butcancelatom); imgbtnclose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW4.dismiss(); popmW1.dismiss(); } }); imgbtnback = (ImageButton) vwLayout.findViewById(R.id.btnbackatom); imgbtnback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW4.dismiss(); } }); } }); btnphysico = (Button) vwLayout.findViewById(R.id.btnphyche); btnphysico.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { physico(); } private void physico() { LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View vwLayout = inflater.inflate(R.layout.physico, (ViewGroup) ((Activity) ctx).findViewById(R.id.physi)); popmW5 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true); popmW5.setBackgroundDrawable(new BitmapDrawable()); popmW5.setOutsideTouchable(true); popmW1.setOutsideTouchable(true); popmW5.showAtLocation(vwLayout, Gravity.CENTER, 0, 30); btnseletone = (Button) vwLayout.findViewById(R.id.btnphyone); btnseletone.setText( Html.fromHtml("Atomic Mass Unit<br/><small>1.660538782*10<sup>-27</sup>Kg</small>")); btnseletone.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW5.dismiss(); popmW1.dismiss(); mHandler.insert("1.660538782e-27"); } }); btnselettwo = (Button) vwLayout.findViewById(R.id.btnphytwo); btnselettwo.setText(Html.fromHtml( "Avogadro Constant<br/><small>6.02214179*10<sup>23</sup>mol<sup>-1</sup></small>")); btnselettwo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW5.dismiss(); popmW1.dismiss(); mHandler.insert("6.02214179e-23"); } }); btnseletthree = (Button) vwLayout.findViewById(R.id.btnphythree); btnseletthree.setText( Html.fromHtml("Faraday Constant<br/><small>96,458.3399 C.mol<sup>-1</sup></small>")); btnseletthree.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW5.dismiss(); popmW1.dismiss(); mHandler.insert("964853399"); } }); btnseletfour = (Button) vwLayout.findViewById(R.id.btnphyfour); btnseletfour.setText(Html.fromHtml( "Molar Gas Constant<br/><small>8.314472 J.mol<sup>-1</sup>.K<sup>-1</sup></small>")); btnseletfour.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW5.dismiss(); popmW1.dismiss(); mHandler.insert("8314472"); } }); btnseletfive = (Button) vwLayout.findViewById(R.id.btnphyfive); btnseletfive.setText(Html.fromHtml( "Boltzmann Constant<br/><small>1.3806504*10<sup>-23</sup>J.K<sup>-1</sup></small>")); btnseletfive.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW5.dismiss(); popmW1.dismiss(); mHandler.insert("13806504e-23"); } }); btnseletsix = (Button) vwLayout.findViewById(R.id.btnphysix); btnseletsix.setText(Html.fromHtml( "Stefan-Boltzmann Constant<br/><small>5.6704*10<sup>-8</sup>W.m<sup>-2</sup>.K<sup>-4</sup></small>")); btnseletsix.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW5.dismiss(); popmW1.dismiss(); mHandler.insert("5.6704e-8"); } }); btnseletseven = (Button) vwLayout.findViewById(R.id.btnphyseven); btnseletseven .setText(Html.fromHtml("Electron Volt<br/><small>1.602176487*10<sup>-19</sup>J</small>")); btnseletseven.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW5.dismiss(); popmW1.dismiss(); mHandler.insert("1.602176487e-19"); } }); imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.butcancelphy); imgbtnclose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW1.dismiss(); popmW5.dismiss(); } }); imgbtnback = (ImageButton) vwLayout.findViewById(R.id.btnbackphy); imgbtnback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW5.dismiss(); } }); } }); // other // option--------------------------------------------------------------------------- btnOther = (Button) vwLayout.findViewById(R.id.btnother); btnOther.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Other(); popmW1.dismiss(); } private void Other() { // Toast.makeText(getApplicationContext(), "other", // Toast.LENGTH_SHORT).show(); LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View vwLayout = inflater.inflate(R.layout.other, (ViewGroup) ((Activity) ctx).findViewById(R.id.other)); popmW6 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true); popmW6.setBackgroundDrawable(new BitmapDrawable()); popmW6.setOutsideTouchable(true); popmW1.setOutsideTouchable(true); popmW6.showAtLocation(vwLayout, Gravity.CENTER, 0, 30); btnseletone = (Button) vwLayout.findViewById(R.id.btngravity); btnseletone.setText(Html.fromHtml("Standard Gravity<br/><small>9.80665 m.s<sup>-2</sup></small>")); btnseletone.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW6.dismiss(); popmW1.dismiss(); mHandler.insert("9.80665"); } }); imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.butcancelother); imgbtnclose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW6.dismiss(); popmW1.dismiss(); } }); imgbtnback = (ImageButton) vwLayout.findViewById(R.id.btnbackother); imgbtnback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW6.dismiss(); popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 30); } }); } }); }
From source file:com.android.talkbacktests.testsession.PopupViewTest.java
/** * Shows a PopupWindow at the anchor view with given window height and list size. *///from w w w. j a v a 2s . c om private void showPopupWindow(View button, int height, int listSize, boolean useDefaultInflater) { final Context context = button.getContext(); final ListView listView = new ListView(context); final BaseAdapter adapter; if (useDefaultInflater) { adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, android.R.id.text1, createSampleArray(listSize)); } else { adapter = new MyAdapter(button.getContext(), createSampleArray(listSize)); } listView.setAdapter(adapter); listView.setVerticalScrollBarEnabled(true); listView.setBackgroundColor(0xFFFFFF); final PopupWindow window = new PopupWindow(listView, ViewGroup.LayoutParams.WRAP_CONTENT, height, true); window.setBackgroundDrawable(context.getResources().getDrawable(android.R.drawable.editbox_background)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (window.isShowing()) { window.dismiss(); } } }); PopupWindowCompat.showAsDropDown(window, button, 0, 0, Gravity.NO_GRAVITY); }
From source file:org.kaaproject.kaa.demo.iotworld.smarthome.widget.SmartHomeToolbar.java
public void setCustomToolbarContentEnabled(boolean enabled) { mCustomContentVisible = enabled;/* w ww. ja v a 2s . co m*/ if (mCustomContent != null && mCustomContentVisible) { if (mCustomContentViewWidth < mCustomContentMinWidth) { if (mToolbarCustomContentView.getChildCount() > 0) { mToolbarCustomContentView.removeAllViews(); } if (mPopupContainer.getChildCount() == 0) { mPopupContainer.addView(mCustomContent, mCustomContentPopupViewLayoutParams); mPopupContainer.setCardBackgroundColor(mBackgroundColor); } int popupWidth = (int) (getWidth() * 0.7); if (mPopup == null) { mPopup = new PopupWindow(mPopupContainer, popupWidth, mCustomContentHeight, true); mPopup.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); mPopup.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss() { mCustomContentVisible = false; } }); } else { mPopup.setWidth(popupWidth); } PopupWindowCompat.showAsDropDown(mPopup, this, getWidth() - popupWidth, 0, Gravity.TOP | Gravity.LEFT); } else { if (mPopupContainer.getChildCount() > 0) { mPopupContainer.removeAllViews(); } if (mToolbarCustomContentView.getChildCount() == 0) { mToolbarCustomContentView.addView(mCustomContent, mCustomContentViewLayoutParams); } } } if (!mCustomContentVisible && mPopup != null && mPopup.isShowing()) { mPopup.dismiss(); } if (mCustomContent != null) { mCustomContent.setVisibility(mCustomContentVisible ? View.VISIBLE : View.GONE); } }
From source file:net.quduo.pixel.interfaces.android.fragment.ChatFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this.inflater = inflater; View v = inflater.inflate(R.layout.fragment_chat, container, false); mChatListView = (ListView) v.findViewById(R.id.chat_list_view); // TODO: ?/*w w w . j ava 2 s . c o m*/ mSourceDataList = new ArrayList<ChatListDataModel>(); ChatListDataModel sourceData = new ChatListDataModel(); sourceData.setChatAvatar(R.drawable.default_contact_action_01); sourceData.setChatTitle("?"); sourceData.setChatSummary(":?, ..."); mSourceDataList.add(sourceData); ChatListDataModel sourceData1 = new ChatListDataModel(); sourceData1.setChatAvatar(R.drawable.default_contact_action_04); sourceData1.setChatTitle(""); sourceData1.setChatSummary("?"); mSourceDataList.add(sourceData1); ChatListDataModel sourceData2 = new ChatListDataModel(); sourceData2.setChatAvatar(R.drawable.default_contact_action_03); sourceData2.setChatTitle(""); sourceData2.setChatSummary("?..."); mSourceDataList.add(sourceData2); ChatListDataModel sourceData3 = new ChatListDataModel(); sourceData3.setChatAvatar(R.drawable.default_contact_action_02); sourceData3.setChatTitle(""); sourceData3.setChatSummary("?"); mSourceDataList.add(sourceData3); // TODO ContextMenu final ArrayList<HashMap<String, Object>> mPopupWindowListItem = new ArrayList<HashMap<String, Object>>(); HashMap<String, Object> map1 = new HashMap<String, Object>(); // map1.put("item_image", R.drawable.icon_message); map1.put("item_icon", R.string.icon_chat_add_group); // map1.put("item_text", "" + i + ""); map1.put("item_title", "??"); mPopupWindowListItem.add(map1); HashMap<String, Object> map2 = new HashMap<String, Object>(); // map2.put("item_image", R.drawable.icon_message); map2.put("item_icon", R.string.icon_chat_add_group); // map2.put("item_text", "" + i + ""); map2.put("item_title", ""); mPopupWindowListItem.add(map2); mChatListAdapter = new ChatListAdapter(this.getActivity(), mSourceDataList); mChatListView.setAdapter(mChatListAdapter); mChatListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (DEBUG) Log.d(TAG, mSourceDataList.get(i).getChatTitle()); Intent intent = new Intent(getActivity(), ChatFormActivity.class); getActivity().startActivity(intent); getActivity().finish(); // ? getActivity().overridePendingTransition(R.anim.activity_open_enter, R.anim.activity_close_exit); } }); mChatListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View v, int i, long l) { if (DEBUG) Log.d(TAG, mSourceDataList.get(i).getChatTitle()); // ?? View contextMenuView = inflater.inflate(R.layout.layout_common_context_menu, null); // PopupWindow final PopupWindow popupWindow = new PopupWindow(contextMenuView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, false); // ??? // new ColorDrawable(0) getResources().getDrawable(R.drawable.popup_window_background) popupWindow.setBackgroundDrawable(new ColorDrawable(0x90000000)); // ?? // popupWindow.setOutsideTouchable(true); // ?? popupWindow.setFocusable(true); // ? // popupWindow.setAnimationStyle(R.style.PopupAnimation); // ? // popupWindow.setOnDismissListenerd(new PopupWindow.OnDismissListener(){}); /* // PopupWindow,PopupWindow popupWindow.setTouchInterceptor(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { popupWindow.dismiss(); return true; } return false; } }); */ popupWindow.getContentView().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { popupWindow.dismiss(); } }); if (popupWindow.isShowing()) { // ??????????? popupWindow.dismiss(); } else { // SimpleAdapter mSimpleAdapter = new SimpleAdapter(getApplicationContext(), mPopupWindowListItem, R.layout.main_popup_menu_item, new String[]{"item_icon", "item_title"}, new int[]{R.id.popup_menu_item_icon, R.id.popup_menu_item_title}); BaseAdapter mSimpleAdapter = new BaseAdapter() { @Override public int getCount() { return mPopupWindowListItem.size(); } @Override public Object getItem(int i) { return null; } @Override public long getItemId(int i) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(getActivity()); convertView = inflater.inflate(R.layout.list_item_common_context_menu, parent, false); } // TextView popupMenuItemIcon = (TextView) convertView.findViewById(R.id.popup_menu_item_icon); // if (DEBUG) Log.d(TAG, "item_icon:" + mPopupWindowListItem.get(position).get("item_icon")); // popupMenuItemIcon.setTypeface(typeface); // if (popupMenuItemIcon.getTypeface() != typeface) { // popupMenuItemIcon.setTypeface(typeface); // } // popupMenuItemIcon.setText(Integer.valueOf(mPopupWindowListItem.get(position).get("item_icon").toString())); TextView popupMenuItemTitle = (TextView) convertView .findViewById(R.id.context_menu_action_text_view); popupMenuItemTitle .setText(mPopupWindowListItem.get(position).get("item_title").toString()); return convertView; } }; TextView contextMenuTitle = (TextView) contextMenuView.findViewById(R.id.context_menu_title); contextMenuTitle.setText(mSourceDataList.get(i).getChatTitle()); ListView mPopupMenuListView = (ListView) contextMenuView .findViewById(R.id.context_menu_list_view); mPopupMenuListView.setAdapter(mSimpleAdapter); // ? // PopupWindow??View?x,y????? // popupWindow.showAsDropDown(v, -460, 0); // ?View?,?parent????-90 // Gravity.TOP|Gravity.LEFT, 0, 150 popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0); popupWindow.update(); } return true; } }); // mChatListView.setOnItemSelectedListener(); // #ContextMenu // this.unregisterForContextMenu(mChatListView); // mChatListView.setOnCreateContextMenuListener(null); // this.registerForContextMenu(mChatListView); return v; }
From source file:fr.univsavoie.ltp.client.map.Popup.java
/** * Afficher sur la map un popup qui propose a l'utilisateur * de mettre a jours son status//from w w w . j a v a2s .co m */ public final void popupPublishStatus() { 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 ScrollView viewGroup = (ScrollView) this.activity.findViewById(R.id.popupStatus); LayoutInflater layoutInflater = (LayoutInflater) this.activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = layoutInflater.inflate(R.layout.popup_set_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); } }); /* * Evenements composants du PopupWindow */ // Ecouteur d'vnement sur le bouton pour se dconnecter Button publish = (Button) layout.findViewById(R.id.btStatusPublish); publish.setOnClickListener(new OnClickListener() { public void onClick(View v) { EditText userStatus = (EditText) layout.findViewById(R.id.fieldUserStatus); if (userStatus.getText().toString().length() == 0) { Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show(); popupPublishStatus.dismiss(); } else if (userStatus.getText().toString().length() < 3) { Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show(); popupPublishStatus.dismiss(); } else { String json = "{\"ltp\":{\"application\":\"Client LTP\",\"status\":{\"lon\" : \"" + String.valueOf(activity.getLongitude()) + "\",\"lat\" : \"" + String.valueOf(activity.getLatitude()) + "\",\"content\" : \"" + userStatus.getText().toString() + "\"}}}"; activity.getSession().postJSON("https://jibiki.univ-savoie.fr/ltpdev/rest.php/api/1/statuses", "STATUSES", json); Toast.makeText(activity, "Status mise a jours !", Toast.LENGTH_LONG).show(); popupPublishStatus.dismiss(); // Actualise les marqueurs activity.displayFriends(); } } }); }
From source file:com.trukr.shipper.fragment.RequestStatus.java
private void process() { more_Icon.setOnClickListener(new View.OnClickListener() { @Override//from w w w .j av a2 s .co m public void onClick(View v) { showImageAlert(); } }); driverProfile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View popUpView = getLayoutInflater().inflate(R.layout.activity_map_popup, null); // inflating popup layout mpopup = new PopupWindow(popUpView, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); //Creation of popup mpopup.setAnimationStyle(android.R.style.Animation_Dialog); mpopup.showAtLocation(popUpView, Gravity.BOTTOM, 0, 0); // Displaying popup RoundedImageView pop_up_driverimage = (RoundedImageView) popUpView.findViewById(R.id.pop_up_image); TextView driverName = (TextView) popUpView.findViewById(R.id.tv_drivername); TextView licenseNumber = (TextView) popUpView.findViewById(R.id.tv_driverlicenseno); TextView usDotnumber = (TextView) popUpView.findViewById(R.id.tv_usdotno); TextView mcNumber = (TextView) popUpView.findViewById(R.id.tv_mcno); TextView licensePlates = (TextView) popUpView.findViewById(R.id.tv_licenseplates); TextView checkSafetyRating = (TextView) popUpView.findViewById(R.id.tv_checksafetyrating); TextView insuranceDocument = (TextView) popUpView.findViewById(R.id.tv_insurancedocument); ImageView moreIcon = (ImageView) popUpView.findViewById(R.id.fragment_btn_currentjobs); moreIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showImageAlert(); } }); checkSafetyRating.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(mContext, WebViewDisplay.class); i.putExtra("insurancedocument", 1); startActivity(i); } }); insuranceDocument.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(mContext, WebViewDisplay.class); i.putExtra("insuranceValue", insuranceValue); startActivity(i); } }); driverName.setText(driversname); System.out.println("driversimage--->" + driverImage); try { Picasso.with(getApplicationContext()).load(driverImage).into(pop_up_driverimage); } catch (Exception e) { e.printStackTrace(); } licenseNumber.setText(": " + driverLicenseValue); usDotnumber.setText(": " + driverUsDotNumberValue); mcNumber.setText(": " + driverMcNumberValue); licensePlates.setText(": " + driverLicensePlatesValue); popup = (LinearLayout) popUpView.findViewById(R.id.map_activity_popup); RoundedImageView view = (RoundedImageView) popUpView.findViewById(R.id.pop_up_image); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mpopup.dismiss(); } }); } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(mContext, SlidingDrawer.class); intent.putExtra("OrderStatus", 1); startActivity(intent); } }); notification.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(RequestStatus.this, Notification.class); startActivity(intent); } }); }
From source file:com.trail.octo.UploadDocs.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_upload_docs); sharedPreferences = getSharedPreferences("user_data", MODE_PRIVATE); user_name = sharedPreferences.getString("user_name", ""); sharedPreferences_docs = getSharedPreferences("docs_data", MODE_PRIVATE); upload_docs_pan_select = (ImageView) findViewById(R.id.upload_docs_pan_select); upload_docs_driving_select = (ImageView) findViewById(R.id.upload_docs_driving_select); upload_docs_aadhar_select = (ImageView) findViewById(R.id.upload_docs_aadhar_select); upload_docs_voter_select = (ImageView) findViewById(R.id.upload_docs_voter_select); upload_docs_passport_select = (ImageView) findViewById(R.id.upload_docs_passport_select); if (sharedPreferences_docs.getString("pancard", "").equals("")) pan = true;// w w w .j a va 2s. com else upload_docs_pan_select.setVisibility(View.VISIBLE); if (sharedPreferences_docs.getString("drivinglicense", "").equals("")) driving = true; else upload_docs_driving_select.setVisibility(View.VISIBLE); if (sharedPreferences_docs.getString("voterid", "").equals("")) voter = true; else upload_docs_voter_select.setVisibility(View.VISIBLE); if (sharedPreferences_docs.getString("aadharcard", "").equals("")) aadhar = true; else upload_docs_aadhar_select.setVisibility(View.VISIBLE); if (sharedPreferences_docs.getString("passport", "").equals("")) passport = true; else upload_docs_passport_select.setVisibility(View.VISIBLE); if (savedInstanceState != null) file_type = savedInstanceState.getString("file_type"); imageView_camera = (ImageView) findViewById(R.id.upload_docs_camera); imageView_gallery = (ImageView) findViewById(R.id.upload_docs_gallery); imageView_profilepic = (ImageView) findViewById(R.id.upload_docs_profile_pic); linearLayout_aadhar = (LinearLayout) findViewById(R.id.upload_docs_aadhar); linearLayout_driving = (LinearLayout) findViewById(R.id.upload_docs_driving); linearLayout_pan = (LinearLayout) findViewById(R.id.upload_docs_pan); linearLayout_voter = (LinearLayout) findViewById(R.id.upload_docs_voter); linearLayout_passport = (LinearLayout) findViewById(R.id.upload_docs_passport); button_submit = (Button) findViewById(R.id.upload_docs_submit); button_submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (user_name.equals("")) { Intent intent = new Intent(getApplicationContext(), LoginActivity.class); startActivity(intent); } else { Intent intent = new Intent(getApplicationContext(), Home.class); startActivity(intent); } } }); imageView_camera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (askCameraPermission()) { file_type = "profilepic"; Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, REQUEST_CAMERA); } } }); imageView_gallery.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (askGalleryPermission()) { file_type = "profilepic"; Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE); } } }); LayoutInflater layoutInflater = (LayoutInflater) getBaseContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.loading_popup_window, null); popupWindow = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true); view_select = layoutInflater.inflate(R.layout.popup_image_capture, null); popup_imageView_camera = (ImageView) view_select.findViewById(R.id.popup_imageView_camera); popup_imageView_gallery = (ImageView) view_select.findViewById(R.id.popup_imageView_gallary); popupWindow_select_source = new PopupWindow(view_select, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); popupWindow_select_source.setFocusable(false); popupWindow_select_source.setBackgroundDrawable(new BitmapDrawable()); popupWindow_select_source.setOutsideTouchable(true); popup_imageView_gallery.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (askGalleryPermission()) { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE); } } }); popup_imageView_camera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (askCameraPermission()) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, REQUEST_CAMERA); } } }); linearLayout_driving.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (driving) { file_type = "drivinglicense"; popupWindow_select_source.showAtLocation(view_select, Gravity.CENTER, 0, 40); } else Toast.makeText(getApplicationContext(), "You have already uploaded the Driving license", Toast.LENGTH_SHORT).show(); } }); linearLayout_pan.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (pan) { file_type = "pancard"; popupWindow_select_source.showAtLocation(view_select, Gravity.CENTER, 0, 40); } else Toast.makeText(getApplicationContext(), "You have already uploaded the Pan Card", Toast.LENGTH_SHORT).show(); } }); linearLayout_aadhar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (aadhar) { file_type = "aadharcard"; popupWindow_select_source.showAtLocation(view_select, Gravity.CENTER, 0, 40); } else Toast.makeText(getApplicationContext(), "You have already uploaded the Aadhar Card", Toast.LENGTH_SHORT).show(); } }); linearLayout_voter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (voter) { file_type = "voterid"; popupWindow_select_source.showAtLocation(view_select, Gravity.CENTER, 0, 40); } else Toast.makeText(getApplicationContext(), "You have already uploaded the Voter id", Toast.LENGTH_SHORT).show(); } }); linearLayout_passport.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (passport) { file_type = "passport"; popupWindow_select_source.showAtLocation(view_select, Gravity.CENTER, 0, 40); } else Toast.makeText(getApplicationContext(), "You have already uploaded the Passport", Toast.LENGTH_SHORT).show(); } }); }
From source file:edu.stanford.cs.sing.helena.DeviceControlActivity.java
public void onShowPopup(View view, final int position) { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); // inflate the custom popup layout final View inflatedView = layoutInflater.inflate(R.layout.observer_view, null, false); // find the ListView in the popup layout mFireLitDisplay = false;/* www . ja v a 2 s .co m*/ Firestorm mFire = mFirestormArray.get(position); Log.d(TAG, "FIRE ID " + mFire.id); // get device size Display display = getWindowManager().getDefaultDisplay(); final Point size = new Point(); display.getSize(size); // set height depends on the device size popWindow = new PopupWindow(inflatedView, size.x - 50, size.y - 200, true); // set a background drawable with rounders corners popWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.dialog_background)); // make it focusable to show the keyboard to enter in `EditText` popWindow.setFocusable(true); // make it outside touchable to dismiss the popup window popWindow.setOutsideTouchable(true); // show the popup at bottom of the screen and set some margin at bottom ie, // popWindow.showAtLocation(getCurrentFocus(), Gravity.TOP, 0, 100); //showAtLocation(v, Gravity.BOTTOM, 0,100); findViewById(R.id.fire_list).post(new Runnable() { public void run() { popWindow.showAtLocation(findViewById(R.id.fire_list), Gravity.CENTER, 0, 0); addDetailList(inflatedView, position); } }); }