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