Silicon Valley Social 13--new Group page

Source: Internet
Author: User

1) Page layout

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "xmlns:app=" Http://schemas.android.com/apk/res-auto "xmlns:tools=" Http://schemas.android.com/tools "Andro Id:layout_width= "Match_parent" android:layout_height= "match_parent" android:orientation= "vertical" > <com.hy        Phenate.easeui.widget.EaseTitleBar android:layout_width= "match_parent" android:layout_height= "Wrap_content" app:titlebartitle= "new Group" > </com.hyphenate.easeui.widget.EaseTitleBar> <edittext android:id = "@+id/et_newgroup_name" android:layout_width= "match_parent" android:layout_height= "Wrap_content" and Roid:layout_margin= "5DP" android:hint= "group name" android:textsize= "20sp"/> <edittext android:id = "@+id/et_newgroup_desc" android:layout_width= "match_parent" android:layout_height= "150DP" Android:la Yout_margin= "5DP" android:gravity= "Start" android:hint= "group profile" android:textsize= "20sp"/> <linearlayout android:layout_wi            Dth= "Match_parent" android:layout_height= "wrap_content" android:layout_margin= "5DP" > <textview             Android:layout_width= "0DP" android:layout_height= "Wrap_content" android:layout_weight= "1" Android:text= "Whether to expose" android:textsize= "20sp"/> <checkbox android:id= "@+id/c    B_newgroup_public "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "/> </LinearLayout> <linearlayout android:layout_width= "match_parent" android:layout_height= "Wrap_c Ontent "android:layout_margin=" 5DP "> <textview android:layout_width=" 0DP "Androi d:layout_height= "Wrap_content" android:layout_weight= "1" android:text= "open Group invitation" Android:t    Extsize= "20sp"/>    <checkbox android:id= "@+id/cb_newgroup_invite" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content"/> </LinearLayout> <button android:id= "@+id/bt_newgroup_cre Ate "android:layout_width=" match_parent "android:layout_height=" Wrap_content "android:layout_margin=" 5DP "android:background=" @android: Color/holo_green_light "android:text=" create "android:textcolor=" @andro Id:color/white "android:textsize=" 20SP "/></linearlayout>

2) Create a listener for the group button

Create a button's Click event Bt_new_group_create.setonclicklistener (New View.onclicklistener () {@Overridepublic void OnClick (View v) { Jump to contact page get Contact data Intent Intent = new Intent (newgroupactivity.this, pickcontactsactivity.class); Startactivityforresult (Intent, 110);});

3) Select the callback listener on the contact page

@Overrideprotected void Onactivityresult (int requestcode, int resultcode, Intent data) {Super.onactivityresult ( Requestcode, ResultCode, data); if (ResultCode = = RESULT_OK) {//Create Group CreateGroup (Data.getextras (). Getstringarray (" Members "));}}

4) Create a group

Create the group private void CreateGroup (final string[] memberses) {//Get the group name final String groupName = Et_new_group_name.gettext (). To string ();//Gets the description information for the group final String Groupdesc = Et_new_group_desc.gettext (). toString ();//Networking Model.getinstace (). Getgolbalthreadpool (). Execute (new Runnable () {@Overridepublic void run () {String reason = "Apply to join the group"; Emgroupmanager.emgroupstyle GroupStyle = null;//Group Public if (cb_new_group_public.ischecked ()) {if (cb_new_group_ Invite.ischecked ()) {//Group invitation public groupstyle = EMGroupManager.EMGroupStyle.EMGroupStylePublicOpenJoin;} else {// Group Invitation not Public groupstyle = EMGroupManager.EMGroupStyle.EMGroupStylePublicJoinNeedApproval;}} else {//Group not public if (cb_new_group_invite.ischecked ()) {//Group invitation Public Groupstyle = EMGroupManager.EMGroupStyle.EMGroupStylePrivateMemberCanInvite;} else {//Group invitation not public groupstyle = EMGroupManager.EMGroupStyle.EMGroupStylePrivateOnlyOwnerInvite;}} Group parameter settings emgroupmanager.emgroupoptions options = new Emgroupmanager.emgroupoptions ();//group up to how many people options.maxusers = 200;// Create a group type Options.style = grOupstyle;try {///Networking Create Group Emclient.getinstance (). Groupmanager (). CreateGroup (GroupName, Groupdesc, memberses, Reason, options);//Update Uirunonuithread (new Runnable () {@Overridepublic void run () {Toast.maketext (Newgroupactivity.this, "Create a group: "+ GroupName +" Success ", Toast.length_short). Show ();//End current page finish ();}});} catch (Hyphenateexception e) {e.printstacktrace ();//Update Uirunonuithread (new Runnable () {@Overridepublic void run () { Toast.maketext (Newgroupactivity.this, "create Group:" + GroupName + "failed", Toast.length_short). Show ();});}});}

  

Silicon Valley Social 13--new Group page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.