The generation and parsing of Android XML

Source: Internet
Author: User

Main Java

 PackageCom.itheima.xml;Importandroid.app.Activity;ImportAndroid.content.Context;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.widget.Button;ImportAndroid.widget.Toast;Importcom.itheima.xml.util.SmsUtils; Public classMainactivityextendsActivityImplementsOnclicklistener {PrivateContext Mcontext; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); Mcontext= This; //1. Locate the controlButton Bt_backup =(Button) Findviewbyid (r.id.bt_backup); Button Bt_restore=(Button) Findviewbyid (R.id.bt_restore); //2. Set Click eventsBt_backup.setonclicklistener ( This); Bt_restore.setonclicklistener ( This); } @Override Public voidOnClick (View v) {Switch(V.getid ()) { CaseR.id.bt_backup:if(Smsutils.backupsms_android (Mcontext)) {Toast.maketext (Mcontext,"SMS Backup Succeeded", Toast.length_short). Show (); }Else{toast.maketext (Mcontext,"SMS Backup Failed", Toast.length_short). Show (); }             Break;  CaseR.id.bt_restore:intresult =smsutils.restoresms (Mcontext); Toast.maketext (Mcontext,"Successful Recovery" +result+ "text message", Toast.length_short). Show ();  Break; default:             Break; }    }}

 PackageCom.itheima.xml;Importandroid.app.Activity;ImportAndroid.content.Context;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.widget.Button;ImportAndroid.widget.Toast;Importcom.itheima.xml.util.SmsUtils; Public classMainactivityextendsActivityImplementsOnclicklistener {PrivateContext Mcontext; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); Mcontext= This; //1. Locate the controlButton Bt_backup =(Button) Findviewbyid (r.id.bt_backup); Button Bt_restore=(Button) Findviewbyid (R.id.bt_restore); //2. Set Click eventsBt_backup.setonclicklistener ( This); Bt_restore.setonclicklistener ( This); } @Override Public voidOnClick (View v) {Switch(V.getid ()) { CaseR.id.bt_backup:if(Smsutils.backupsms_android (Mcontext)) {Toast.maketext (Mcontext,"SMS Backup Succeeded", Toast.length_short). Show (); }Else{toast.maketext (Mcontext,"SMS Backup Failed", Toast.length_short). Show (); }             Break;  CaseR.id.bt_restore:intresult =smsutils.restoresms (Mcontext); Toast.maketext (Mcontext,"Successful Recovery" +result+ "text message", Toast.length_short). Show ();  Break; default:             Break; }    }}

 PackageCom.itheima.xml.dao;Importjava.util.ArrayList;ImportCom.itheima.xml.bean.SmsBean; Public classSmsdao {//get SMS data and simulate some fake data     Public StaticArraylist<smsbean>getallsms () {ArrayList<SmsBean> arrayList =NewArraylist<smsbean>(); Smsbean Smsbean=NewSmsbean (); Smsbean.id= 1; Smsbean.num= "110"; Smsbean.msg= "Come to the police station and make a statement."; Smsbean.date= "2015-08-29";                        Arraylist.add (Smsbean); Smsbean SmsBean1=NewSmsbean (); Smsbean1.id= 2; Smsbean1.num= "120"; Smsbean1.msg= "What's the latest"; Smsbean1.date= "2015-08-29";                        Arraylist.add (SMSBEAN1); Smsbean smsBean2=NewSmsbean (); Smsbean2.id= 3; Smsbean2.num= "119"; Smsbean2.msg= "Is the fire out?"; Smsbean2.date= "2015-08-29";                                Arraylist.add (SMSBEAN2); returnarrayList; }}

 Package Com.itheima.xml.bean;  Public class Smsbean {    public  String num;      Public String msg;      Public String date;      Public int ID;        }

The generation and parsing of Android XML

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.