Skip to content

Instantly share code, notes, and snippets.

@Reacoder
Created June 10, 2014 02:09
Show Gist options
  • Save Reacoder/c2b613590e616d162d49 to your computer and use it in GitHub Desktop.
Save Reacoder/c2b613590e616d162d49 to your computer and use it in GitHub Desktop.
private OnClickListener popupClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.share_google:
System.out.println("===== share_google");
break;
case R.id.share_facebook:
System.out.println("===== share_facebook");
break;
case R.id.share_twitter:
System.out.println("===== share_twitter");
break;
default:
break;
}
popupWindow.dismiss();
}
};
private void initSharePopup() {
popupLayout = (LinearLayout) LayoutInflater.from(this).inflate(
R.layout.popup_share_layout, null);
popupLayout.findViewById(R.id.share_google).setOnClickListener(
popupClickListener);
popupLayout.findViewById(R.id.share_facebook).setOnClickListener(
popupClickListener);
popupLayout.findViewById(R.id.share_twitter).setOnClickListener(
popupClickListener);
popupWindow = new PopupWindow(popupLayout,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
}
private void showSharePopupMenu(View v) {
if (popupWindow.isShowing()) {
popupWindow.dismiss();
} else {
if (mFullScreen) {
float px = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 10, getResources()
.getDisplayMetrics());
popupWindow.showAsDropDown(v, (int) -px, (int) px);
} else {
popupWindow.showAsDropDown(v);
}
}
}
Can't get action view for ActionBar MenuItem using support library
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == R.id.action_filter){
View view= getActivity().findViewById(R.id.action_filter);
showFilterWindow(view);
}
return super.onOptionsItemSelected(item);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment