List of usage examples for android.widget PopupWindow getContentView
public View getContentView()
Return the view used as the content of the popup window.
From source file:com.fuzz.android.limelight.LimeLight.java
public static void onWindowFocusChanged(Activity activity, boolean hasFocus) { if (hasFocus) { if (firstFocus) { firstFocus = false;/*ww w . j a va 2 s .c om*/ if (mRecorderWindow == null) { onResume(activity); } if (book != null) { mRecorderWindow.setMainWindow(book.getWindow()); PopupWindow popupWindow = book.getWindow(); if (popupWindow != null) { Context context = popupWindow.getContentView().getContext(); if (context != activity) { createDelayedRecordingWindow(activity, 200); } } else { createDelayedRecordingWindow(activity, 200); } } else { createDelayedRecordingWindow(activity, 200); } } } }
From source file:cn.zhangls.android.weibo.ui.weibo.WeiboFrameProvider.java
/** * ????//from w w w. ja v a 2 s . c om * * @param holder * @param status */ private void setupPopupBar(final FrameHolder holder, final Status status) { LayoutInflater layoutInflater = LayoutInflater .from(holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext()); // final View popupView; if (status.isFavorited() && status.getUser().isFollowing()) {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_follow_save_post, holder.binding.flWeiboContainer, false); } else if (!status.isFavorited() && status.getUser().isFollowing()) {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_follow_unsave_post, holder.binding.flWeiboContainer, false); } else if (status.isFavorited() && !status.getUser().isFollowing()) {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_unfollow_save_post, holder.binding.flWeiboContainer, false); } else {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_unfollow_unsave_post, holder.binding.flWeiboContainer, false); } // PopupWindow final PopupWindow popupWindow = new PopupWindow(popupView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); popupWindow.setTouchable(true); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); // popupWindow popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { Animation animation = AnimationUtils.loadAnimation( holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext(), R.anim.rotate_180_end); animation.setDuration(300); animation.setFillAfter(true); holder.binding.fgHomeWeiboPopupBar.startAnimation(animation); } }); popupWindow.setAnimationStyle(R.style.PopupWindowAnimStyle); // popupWindow Item ? if (status.isFavorited()) {// ?????? popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_save_post) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FavoritesAPI favoritesAPI = new FavoritesAPI( mBinding.getRoot().getContext().getApplicationContext(), AccessTokenKeeper.readAccessToken( mBinding.getRoot().getContext().getApplicationContext())); BaseObserver<Favorite> observer = new BaseObserver<Favorite>( mBinding.getRoot().getContext().getApplicationContext()) { @Override public void onNext(Favorite value) { } @Override public void onError(Throwable e) { super.onError(e); } @Override public void onComplete() { } }; favoritesAPI.destroy(observer, status.getId()); popupWindow.dismiss(); } }); } else { popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_unsave_post) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FavoritesAPI favoritesAPI = new FavoritesAPI( mBinding.getRoot().getContext().getApplicationContext(), AccessTokenKeeper.readAccessToken( mBinding.getRoot().getContext().getApplicationContext())); BaseObserver<Favorite> observer = new BaseObserver<Favorite>( mBinding.getRoot().getContext().getApplicationContext()) { @Override public void onNext(Favorite value) { } @Override public void onError(Throwable e) { super.onError(e); } @Override public void onComplete() { } }; favoritesAPI.create(observer, status.getId()); popupWindow.dismiss(); } }); } if (status.getUser().isFollowing()) {// ???? popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_follow) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); } }); } else { popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_unfollow) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); } }); } // ??? holder.binding.fgHomeWeiboPopupBar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (popupWindow != null && !popupWindow.isShowing()) { Animation animation = AnimationUtils.loadAnimation( holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext(), R.anim.rotate_180_start); animation.setDuration(300); animation.setFillAfter(true); holder.binding.fgHomeWeiboPopupBar.startAnimation(animation); popupWindow.showAsDropDown(holder.binding.fgHomeWeiboPopupBar); } } }); }
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: ?/*from w ww. j a v a2s .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:net.quduo.pixel.interfaces.android.fragment.ContactFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_contact, container, false); // 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);/*from w ww . j av a 2 s.co m*/ 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); // Set the adapter mContactListAdapter = new ContactListAdapter(this.getActivity(), mSourceDataList); mListView = (ListView) view.findViewById(R.id.contact_list_view); mListView.setAdapter(mContactListAdapter); // Set OnItemClickListener so we can be notified on item clicks mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (null != mListener) { // Notify the active callbacks interface (the activity, if the // fragment is attached to one) that an item has been selected. // mListener.onFragmentInteraction(DummyContent.ITEMS.get(position).id); } } }); mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View v, int i, long l) { // Log.e(TAG, DummyContent.ITEMS.get(i).content); Log.e(TAG, mSourceDataList.get(i).getContactName()); // ?? 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).getContactName()); 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; } }); mLetterQueryView = (LetterQueryView) view.findViewById(R.id.letter_query_view); mLetterTextDialog = (TextView) view.findViewById(R.id.letter_text_dialog); mLetterQueryView.setTextView(mLetterTextDialog); // ?? mLetterQueryView.setOnTouchingLetterChangedListener(new LetterQueryView.OnTouchingLetterChangedListener() { @Override public void onTouchingLetterChanged(String s) { // ?? int position = mContactListAdapter.getPositionForSection(s.charAt(0)); if (position != -1) { mListView.setSelection(position); } } }); return view; }
From source file:com.android.dialer.DialtactsFragment.java
/** * @author bbk wangchunhe/* www .ja va 2 s . c o m*/ * @Date 2016/07/15 * add PopupWindow OnClickListener * @param popupWindow */ private void popupWindowItemSelect(final PopupWindow popupWindow) { View contentView = popupWindow.getContentView(); RelativeLayout callLogsContainer = (RelativeLayout) contentView .findViewById(R.id.dialtacts_popupwindow_all_calls_cantainer); final TextView callLogsTxt = (TextView) contentView.findViewById(R.id.dialtacts_popupwindow_all_calls_txt); final ImageView callLogsImage = (ImageView) contentView .findViewById(R.id.dialtacts_popupwindow_all_calls_image); RelativeLayout callLogMissedContainer = (RelativeLayout) contentView .findViewById(R.id.dialtacts_popupwindow_call_log_missed_container); final TextView callLogMissedTxt = (TextView) contentView .findViewById(R.id.dialtacts_popupwindow_call_log_missed_txt); final ImageView callLogMissedImage = (ImageView) contentView .findViewById(R.id.dialtacts_popupwindow_call_log_missed_image); ColorStateList colorStateListTxt = getActivity().getColorStateList(R.color.popupwindows_item_text_color); ColorStateList colorStateListImage = getActivity().getColorStateList(R.color.popupwindows_item_image_color); callLogsImage.setImageTintList(colorStateListImage); callLogMissedImage.setImageTintList(colorStateListImage); callLogsTxt.setTextColor(colorStateListTxt); callLogMissedTxt.setTextColor(colorStateListTxt); if (!callLogMissedImage.isSelected()) { callLogsImage.setSelected(true); callLogsTxt.setSelected(true); } callLogsContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { callLogsImage.setSelected(true); callLogsTxt.setSelected(true); callLogMissedImage.setSelected(false); callLogMissedTxt.setSelected(false); showCallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL); // mActionbarNameTxt.setText(getString(R.string.all_calls)); // mDialtactsActionBarController.setActionNameAndMenu(R.string.all_calls,R.string.call_log_missed,R.string.select_call_log); Log.e(TAG, " action Name --1" + mDialtactsActionBarController.getmActionNameTxt().getText()); mDialtactsActionBarController.setActionName(getString(R.string.all_calls)); Log.e(TAG, " action Name --2" + mDialtactsActionBarController.getmActionNameTxt().getText()); mCallLogSelectPopupWindow.dismiss(); } }); callLogMissedContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { callLogsImage.setSelected(false); callLogsTxt.setSelected(false); callLogMissedImage.setSelected(true); callLogMissedTxt.setSelected(true); showCallLogFragment(Calls.MISSED_TYPE); // mActionbarNameTxt.setText(getString(R.string.call_log_missed)); // mDialtactsActionBarController.setActionNameAndMenu(R.string.all_calls,R.string.call_log_missed,R.string.select_call_log); Log.e(TAG, " action Name --3" + mDialtactsActionBarController.getmActionNameTxt().getText()); mDialtactsActionBarController.setActionName(getString(R.string.call_log_missed)); Log.e(TAG, " action Name --4" + mDialtactsActionBarController.getmActionNameTxt().getText()); mCallLogSelectPopupWindow.dismiss(); } }); }