Customize the ShareSDK sharing platform interface and sharesdk Sharing Platform
Custom ShareSDK sharing platform Interface
Run:
Shared by friends:
Note: There are two ways to share a circle of friends: one is to bypass the review, that is, the way shown in the figure, the other is not to bypass the review, and the two methods are different in the circle of friends, the pop-up interfaces for sharing are also different. Set BypassApproval = "true" in shareSDK. xml, that is, BypassApproval is the flag for bypassing the review. If it is set to true, AppId will be ignored.
1. The following message is displayed:SharePopupWindow. java
Package com. example. sharesdk; import android. content. context; import android. graphics. drawable. colorDrawable; import android. view. layoutInflater; import android. view. view; import android. view. view. onClickListener; import android. view. viewGroup. layoutParams; import android. widget. adapterView; import android. widget. adapterView. onItemClickListener; import android. widget. button; import android. widget. gridView; im Port android. widget. popupWindow; import cn. sharesdk. framework. platform; import cn. sharesdk. framework. platform. shareParams; import cn. sharesdk. framework. platformActionListener; import cn. sharesdk. framework. shareSDK;/*** TODO <sharing tool> * @ data: 2:45:38 * @ version: V1.0 */public class extends PopupWindow {private Context context Context; private PlatformActionListener platformActionLis Tener; private ShareParams shareParams; public extends popupwindow (Context cx) {this. context = cx;} public PlatformActionListener getPlatformActionListener () {return platformActionListener;} public void setPlatformActionListener (PlatformActionListener platformActionListener) {this. platformActionListener = platformActionListener;} public void show1_window () {View view = LayoutInflater. from (Context ). inflate (R. layout. pai_layout, null); GridView gridView = (GridView) view. findViewById (R. id. __gridview); gradient adapter = new gradient adapter (context); gridView. setAdapter (adapter); Button btn_cancel = (Button) view. findViewById (R. id. btn_cancel); // cancel the button btn_cancel.setOnClickListener (new OnClickListener () {public void onClick (View v) {// destroy the pop-up box dismiss () ;}}); // set SelectPicPopupW Indow View this. setContentView (view); // set the width of the SelectPicPopupWindow pop-up form this. setWidth (LayoutParams. FILL_PARENT); // set the height of the SelectPicPopupWindow pop-up form this. setHeight (LayoutParams. WRAP_CONTENT); // you can click this to set the SelectPicPopupWindow pop-up window. setFocusable (true); // set SelectPicPopupWindow to bring up the form animation effect this. setAnimationStyle (R. style. animBottom); // instantiate a ColorDrawable color as translucent ColorDrawable dw = new ColorDrawable (0xb0000000 ); // Set the background of the SelectPicPopupWindow pop-up form this. setBackgroundDrawable (dw); gridView. setOnItemClickListener (new incluitemclicklistener (this);} private class extends itemclicklistener implements OnItemClickListener {private PopupWindow pop; public extends itemclicklistener (PopupWindow pop) {this. pop = pop ;}@ Override public void onItemClick (AdapterView <?> Parent, View view, int position, long id) {share (position); pop. dismiss () ;}/ ***** share ** @ param position */private void share (int position) {if (position = 1) {qq ();} else if (position = 4) {qzone ();} else if (position = 5) {publish message () ;}else {Platform plat = null; plat = ShareSDK. getPlatform (context, getPlatform (position); if (platformActionListener! = Null) {plat. setPlatformActionListener (platformActionListener);} plat. share (shareParams) ;}}/*** initialize the sharing parameter ** @ param Internal Model */public void initShareParams (Internal Model) {if (internal model! = Null) {ShareParams sp = new ShareParams (); sp. setShareType (Platform. pai_text); sp. setShareType (Platform. pai_webpage); sp. setTitle (modeling model. getText (); sp. setText (partition model. getText (); sp. setUrl (invalid model. getUrl (); sp. setImageUrl (your model. getImageUrl (); shareParams = sp ;}/ *** obtain platform ** @ param position * @ return */private String getPlatform (int position) {String platform = ""; sw Itch (position) {case 0: platform = "Wechat"; break; case 1: platform = "QQ"; break; case 2: platform = "SinaWeibo"; break; case 3: platform = "WechatMoments"; break; case 4: platform = "QZone"; break; case 5: platform = "Invalid Message"; break;} return platform ;} /*** share to QQ space */private void qzone () {ShareParams sp = new ShareParams (); sp. setTitle (shareParams. getTitle (); sp. setTitleUrl (shareP Arams. getUrl (); // The title hyperlink sp. setText (shareParams. getText (); sp. setImageUrl (shareParams. getImageUrl (); sp. setComment ("my comments on this shared content"); sp. setSite (shareParams. getTitle (); sp. setSiteUrl (shareParams. getUrl (); Platform qzone = ShareSDK. getPlatform (context, "QZone"); qzone. setPlatformActionListener (platformActionListener); // You can call back the sharing event. // You can call back the qzone of the sharing event. share (sp);} private void qq () {ShareParams sp = New ShareParams (); sp. setTitle (shareParams. getTitle (); sp. setTitleUrl (shareParams. getUrl (); // The title hyperlink sp. setText (shareParams. getText (); sp. setImageUrl (shareParams. getImageUrl (); sp. setComment ("my comments on this shared content"); sp. setSite (shareParams. getTitle (); sp. setSiteUrl (shareParams. getUrl (); Platform qq = ShareSDK. getPlatform (context, "QQ"); qq. setPlatformActionListener (platformActionListener); qq. share (Sp);}/*** share to SMS */private void publish message () {ShareParams sp = new ShareParams (); sp. setAddress (""); sp. setText (shareParams. getText () + "this is the URL" + shareParams. getUrl () + "is awesome! "); Platform circle = ShareSDK. getPlatform (context, "Publish message"); circle. setPlatformActionListener (platformActionListener); // sets the sharing Event Callback // executes the image sharing circle. share (sp );}}
2. displayShareAdapter. javaClass
/** @ Title: Your adapter. java * @ Copyright: XXX Co ., ltd. copyright YYYY-YYYY, All rights reserved * @ data: 2:30:32 * @ version: V1.0 */package com. example. sharesdk; import android. content. context; import android. view. layoutInflater; import android. view. view; import android. view. viewGroup; import android. widget. baseAdapter; import android. widget. imageView; import android. widget. textView;/*** TODO <share pop-up box Adapter> * @ data: 2:30:32 * @ version: v1.0 */public class extends adapter extends BaseAdapter {private static String [] shareNames = new String [] {"," QQ "," Weibo "," friends "," QQ space ", "SMS"}; private int [] shareIcons = new int [] {R. drawable. sns_weixin_icon, R. drawable. sns_qqfriends_icon, R. drawable. sns_sina_icon, R. drawable. sns_weixin_timeline_icon, R. drawable. sns_qzone_icon, R. drawable. short_message_nor}; private LayoutInflater inflater; public encryption adapter (Context context) {inflater = LayoutInflater. from (context) ;}@ Override public int getCount () {return shareNames. length ;}@ Override public Object getItem (int position) {return null ;}@ Override public long getItemId (int position) {return 0 ;}@ Override public View getView (int position, view convertView, ViewGroup parent) {if (convertView = null) {convertView = inflater. inflate (R. layout. required _item, null);} ImageView saved icon = (ImageView) convertView. findViewById (R. id. pai_icon); TextView upload Title = (TextView) convertView. findViewById (R. id. __title); icon. setImageResource (shareIcons [position]); your title. setText (shareNames [position]); return convertView ;}}
3. Do not forget to add callback
Note: Make sure that the package name is correct.
Sample source code download link: http://download.csdn.net/detail/gao_chun/8264873