Android Adapter, activity callback data, send SMS

Source: Internet
Author: User

First, the GetView method of rewriting Baseadapter

1 @Override2  PublicView GetView (intposition, View Convertview, ViewGroup parent) {3 view view;4     if(Convertview = =NULL) {5View = View.inflate (Getapplicationcontext (), R.layout.item_phone,NULL);6}Else {7View =Convertview;8     }9TextView name =(TextView) View.findviewbyid (r.id.tv_name);TenTextView phone =(TextView) View.findviewbyid (r.id.tv_phone); One  A Name.settext (personlist.get (position). GetName ()); - Phone.settext (personlist.get (position). Getphone ()); -  the     returnview; -}

Second, arrayadapter structure

1 // Parameters 2 // Context    The current context. 3 // Resource    The resource ID for a layout file containing a TextView to use when instantiating views (only one TextView layout resource). 4 // Objects    The objects to represent in the ListView. 5  Public int resource, list<t> objects)

Third, activity callback data

1, start the new Activity:startactivityforresult (intent, Requestcode);

2. New activity callback data (data saved in intent):

1 setresult (intent); 2 finish ();

3, the original activity to obtain data:

1 @Override2 protected voidOnactivityresult (intRequestcode,intResultCode, Intent data) {3     if(ResultCode = = 10) {4Et_phone.settext (Data.getstringextra ("Phone"));5}Else if(ResultCode = = 20) {6Et_content.settext (Data.getstringextra ("content"));7     }8}

Iv. Sending SMS

1  Public voidbtnsendmsg (View v) {2String content =Et_content.gettext (). toString (). Trim ();3String phone =Et_phone.gettext (). toString (). Trim ();4 5Smsmanager sender =Smsmanager.getdefault ();6Arraylist<string> msglist =sender.dividemessage (content);7 8      for(intI=0;i<msglist.size (); i++){9Sender.sendtextmessage (Phone,NULL, Msglist.get (i),NULL,NULL);Ten     } One}

Android Adapter, activity callback data, send SMS

Related Article

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.