<?xml version= "1.0" encoding= "Utf-8"?> <relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:background= "Color_more_background" >
<textview
Android:id= "@+id/share_text"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_centerhorizontal= "true"
Android:layout_marginbottom= "6DP"
android:layout_margintop= "16DP"
android:text= "Sharing"
Android:textsize= "14sp"/>
<view
Android:id= "@+id/divider_line"
Android:layout_width= "Match_parent"
android:layout_height= "1DP"
android:layout_below= "@id/share_text"
android:background= "@drawable/divider"/>
<linearlayout
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:layout_below= "@id/divider_line"
android:layout_margintop= "15DP"
android:orientation= "Vertical" >
<include layout= "@layout/share_board"/>
</LinearLayout>
</RelativeLayout>
Share_board.xml
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical" >
<gridview
Android:id= "@+id/gridview"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
Android:horizontalspacing= "1DP"
Android:numcolumns= "4"
android:verticalspacing= "1DP" >
</GridView>
</LinearLayout>
Activity_classify_up_item.xml
<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:background= "Color_white" >
<relativelayout
Android:id= "@+id/person_entrys"
Android:layout_width= "Wrap_content"
android:layout_height= "93DP"
android:background= "@drawable/classify_up_background" >
<imageview
Android:id= "@+id/imageview1"
Android:layout_width= "47DP"
android:layout_height= "47DP"
Android:layout_centerhorizontal= "true"
Android:layout_centervertical= "true"
android:contentdescription= "@null"
android:src= "@drawable/android_person_entry"/>
<textview
Android:id= "@+id/textview1"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:layout_below= "@id/imageview1"
android:layout_margintop= "5DP"
android:gravity= "Center"
android:text= "@string/person_entry"
Android:textcolor= "Color_set_textcolor"?
Android:textsize= "12SP"/>
</RelativeLayout>
</RelativeLayout>
Customshareboard. java
public class Customshareboard extends Popupwindow {
Private listPrivate GridView Mtopgridview;
Private Simpleadapter Msimpleadapter;
Private Umsocialservice Mcontroller = Umservicefactory.getumsocialservice ("Com.umeng.share");
Private activity mactivity;
Public Customshareboard (activity activity) {
Super (activity);
This.mactivity = activity;
Initview (activity);
}
private void Inittopgridviewadapter () {
item = new arraylistint data[] = {R.string.umeng_socialize_text_weixin_key, R.string.sina, R.string.umeng_socialize_text_qq_key, R.string.umeng_socialize_text_qq_zone_key};
int imgid[] = {r.drawable.umeng_socialize_wechat, r.drawable.umeng_socialize_wxcircle, R.drawable.umeng_socialize_ qq_on, r.drawable.umeng_socialize_qzone_on};
for (int i = 0; i < data.length; i++) {
hashmap<string, object> map = new hashmap<string, object> ();
Map.put ("Itemimage", Imgid[i]);
Map.put ("ItemName", Mactivity.getresources (). getString (Data[i));
Item.add (map);
}
Msimpleadapter = new Simpleadapter (mactivity, item, R.layout.activity_classify_up_item, new string[] {"ItemImage", " ItemName "}, new int[] {r.id.imageview1, r.id.textview1});
}
@SuppressWarnings ("deprecation")
private void Initview (context context) {
View Rootview = layoutinflater.from (context). Inflate (R.layout.custom_board, NULL);
Mtopgridview = (GridView) Rootview.findviewbyid (R.id.gridview);
Inittopgridviewadapter ();
Mtopgridview.setadapter (Msimpleadapter);
Mtopgridview.setonitemclicklistener (New Onitemclicklistener () {
@Override
public void Onitemclick (adapterview<?> arg0, View arg1, int arg2, long arg3) {
if (arg2==0) {
Performshare (Share_media. Weixin);
}else if (arg2==1) {
Performshare (Share_media. SINA);
}else if (arg2==2) {
Performshare (Share_media. QQ);
}else if (arg2==3) {
Performshare (Share_media. QZONE);
}
}
});
Setcontentview (Rootview);
SetWidth (layoutparams.match_parent);
SetHeight (layoutparams.wrap_content);
Setfocusable (TRUE);
Setbackgrounddrawable (New bitmapdrawable ());
Settouchable (TRUE);
}
private void Performshare (Share_media platform) {
Mcontroller.postshare (mactivity, Platform, New Snspostlistener () {
@Override
public void OnStart () {
}
@Override
public void OnComplete (Share_media platform, int ecode, socializeentity entity) {
String Showtext = platform.tostring ();
if (Ecode = = statuscode.st_code_successed) {
Showtext + + "platform sharing success";
} else {
Showtext + + "platform sharing failure";
}
Toast.maketext (mactivity, Showtext, Toast.length_short). Show ();
Dismiss ();
}
});
}
}
Open the Sharing panel trigger event
Button.setonclicklistener (new View.onclicklistener) {
Postshare ();
}
private void Postshare () {
Customshareboard Shareboard = new Customshareboard (this);
Shareboard.showatlocation (This.getwindow (). Getdecorview (), Gravity.bottom, 0, 0);
}