In doing share this piece of time, use the function of the popup box, also must have a bit of hit back key, the same can undo the display popup box, so he wrote one, all look at the code:
public class Shareboardpicker implements Onclicklistener {private Context mcontext;private Sharepobupwindow mpopupwindow;//Share Box Private linearlayout layout;private relativelayout mweixinlayout;//share Private relativelayout mweixincirclelayout;//friend Circle Share private relativelayout msinalayout;//Sina Weibo share private relativelayout mqqzonelayout;// QQ space sharing private Umengshare share;public Shareboardpicker (context context, String infostr) {mcontext = Context;share = new UM Engshare (CONTEXT,INFOSTR); init ();} Public Shareboardpicker (context context, string title, string URL, string imgurl) {Mcontext = Context;share = new Umengsha Re (context,title,url,imgurl); init ();} public void init () {Layoutinflater inflater = Layoutinflater.from (mcontext); layout = (LinearLayout) inflater.inflate ( R.layout.shareboard_picker,null); mweixinlayout = (relativelayout) Layout.findviewbyid (R.id.weixin); Mweixincirclelayout = (relativelayout) Layout.findviewbyid (r.id.weixin_circle); msinalayout = (RelativeLayout) Layout.findviewbyid (R.id.sina); MQQzonelayout = (relativelayout) Layout.findviewbyid (r.id.email_share); Mweixinlayout.setonclicklistener (this); Mweixincirclelayout.setonclicklistener (This), Msinalayout.setonclicklistener (this); Mqqzonelayout.setonclicklistener (this); Mpopupwindow = new Sharepobupwindow (Mcontext,layout, LayoutParams.MATCH_ Parent,layoutparams.wrap_content, True);//settings Click the window outside the window disappears mpopupwindow.setoutsidetouchable (TRUE);//Set this parameter to get the focus, Otherwise, you cannot click Mpopupwindow.setfocusable (TRUE); Mpopupwindow.setbackgrounddrawable (new Colordrawable (color.transparent)); Mpopupwindow.setanimationstyle (R.style.picker_anim_style);} public void Show () {windowmanager.layoutparams LP = (Activity) mcontext). GetWindow (). GetAttributes (); lp.alpha = 0.5f; /0.0-1.0 (Activity) mcontext). GetWindow (). SetAttributes (LP); layout.setfocusable (true);// Set the view to listen for event Layout.setfocusableintouchmode (TRUE);//Set the view to listen for event Layout.setonkeylistener (new Onkeylistener () { public boolean OnKey (View v, int keycode, keyevent event) {if (keycode = = Keyevent.keycode_back &&Amp Mpopupwindow! = null) {dismiss ();} return true;}}); Mpopupwindow.update (); mpopupwindow.showatlocation (layout, gravity.bottom, 0, 0);} public void Dismiss () {windowmanager.layoutparams LP = (Activity) mcontext). GetWindow (). GetAttributes (); Lp.alpha = 1.0f; 0.0-1.0 (Activity) mcontext). GetWindow (). SetAttributes (LP); Mpopupwindow.dismiss (); mpopupwindow = null; (( Activity). Mcontext. GetWindow (). SetAttributes (LP);} /** * for use in activity * * @return */public void activityresult (int requestcode, int resultcode, Intent data) {Share.activi Tyresult (Requestcode, ResultCode, data);} @Overridepublic void OnClick (View v) {//TODO auto-generated method Stubswitch (V.getid ()) {case R.ID.WEIXIN:SHARE.STARTW Eixinshare ();d Ismiss (); break;case r.id.weixin_circle:share.startweixincircleshare ();d Ismiss (); break;case R.id.sina:share.startsinashare ();d Ismiss (), Break;case r.id.email_share:share.startemailshare ();d Ismiss (); Default:dismiss (); break;}} Class Sharepobupwindow extends Popupwindow {private Context Mycontext; @Overridepublic void Dismiss () {//TODO auto-generated method Stubwindowmanager.layoutparams LP = ((Activity) m Ycontext). GetWindow (). GetAttributes (); lp.alpha = 1.0f; 0.0-1.0 (Activity) mycontext). GetWindow (). SetAttributes (LP); Super.dismiss ();} Public Sharepobupwindow () {}public Sharepobupwindow (Context context,view contentview, int width, int height, Boolean focusable) {Super (Contentview, width, height, focusable); mycontext = Context;}}}
Customizing the Pobupwindow pop-up box