博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android xml的生成与解析
阅读量:6584 次
发布时间:2019-06-24

本文共 3982 字,大约阅读时间需要 13 分钟。

Main java

package com.itheima.xml;import android.app.Activity;import android.content.Context;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.Toast;import com.itheima.xml.util.SmsUtils;public class MainActivity extends Activity implements OnClickListener {    private Context mContext;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        mContext = this;        //1.找到控件        Button bt_backup = (Button) findViewById(R.id.bt_backup);        Button bt_restore = (Button) findViewById(R.id.bt_restore);        //2.设置点击事件        bt_backup.setOnClickListener(this);        bt_restore.setOnClickListener(this);    }    @Override    public void onClick(View v) {        switch (v.getId()) {        case R.id.bt_backup:            if(SmsUtils.backupSms_android(mContext)){                Toast.makeText(mContext, "短信备份成功", Toast.LENGTH_SHORT).show();            }else{                Toast.makeText(mContext, "短信备份失败", Toast.LENGTH_SHORT).show();            }            break;        case R.id.bt_restore:            int result = SmsUtils.restoreSms(mContext);            Toast.makeText(mContext, "成功恢复"+result+"条短信", Toast.LENGTH_SHORT).show();            break;        default:            break;        }    }}

 

 

 

 

package com.itheima.xml;import android.app.Activity;import android.content.Context;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.Toast;import com.itheima.xml.util.SmsUtils;public class MainActivity extends Activity implements OnClickListener {    private Context mContext;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        mContext = this;        //1.找到控件        Button bt_backup = (Button) findViewById(R.id.bt_backup);        Button bt_restore = (Button) findViewById(R.id.bt_restore);        //2.设置点击事件        bt_backup.setOnClickListener(this);        bt_restore.setOnClickListener(this);    }    @Override    public void onClick(View v) {        switch (v.getId()) {        case R.id.bt_backup:            if(SmsUtils.backupSms_android(mContext)){                Toast.makeText(mContext, "短信备份成功", Toast.LENGTH_SHORT).show();            }else{                Toast.makeText(mContext, "短信备份失败", Toast.LENGTH_SHORT).show();            }            break;        case R.id.bt_restore:            int result = SmsUtils.restoreSms(mContext);            Toast.makeText(mContext, "成功恢复"+result+"条短信", Toast.LENGTH_SHORT).show();            break;        default:            break;        }    }}

 

package com.itheima.xml.dao;import java.util.ArrayList;import com.itheima.xml.bean.SmsBean;public class SmsDao {    //获取短信数据,模拟一些假数据    public static ArrayList
getAllSms() { ArrayList
arrayList = new ArrayList
(); SmsBean smsBean = new SmsBean(); smsBean.id = 1; smsBean.num = "110"; smsBean.msg = "来警局做个笔录"; smsBean.date = "2015-08-29"; arrayList.add(smsBean); SmsBean smsBean1 = new SmsBean(); smsBean1.id = 2; smsBean1.num = "120"; smsBean1.msg = "最近咋样"; smsBean1.date = "2015-08-29"; arrayList.add(smsBean1); SmsBean smsBean2 = new SmsBean(); smsBean2.id = 3; smsBean2.num = "119"; smsBean2.msg = "火灭了吗"; smsBean2.date = "2015-08-29"; arrayList.add(smsBean2); return arrayList; }}

 

 

package com.itheima.xml.bean;public class SmsBean {    public String num ;    public String msg;    public String date;    public int id;        }

 

转载于:https://www.cnblogs.com/liangqiyuan/p/5689185.html

你可能感兴趣的文章
自我介绍
查看>>
截取指定网站Html编码
查看>>
作业一 统计软件简介与数据操作
查看>>
css布局
查看>>
HBase-java api 基本操作
查看>>
POJ2229 Sumsets
查看>>
在LINQ-TO-SQL中实现“级联删除”的方法
查看>>
lemur run PLSA
查看>>
HTTP中的header头解析说明
查看>>
MVC3.0原理学习及总结
查看>>
删除windows中的库、家庭组、收藏夹
查看>>
war 宽度变窄
查看>>
set p4 environment in windows
查看>>
pl/sql development 查询的数据复制到excel
查看>>
自定义指令的参数
查看>>
python实现进度条
查看>>
Android 一个应用启动另一个应用的说明
查看>>
阿里云CentOS7服务器利用LVM分区挂载磁盘全记录
查看>>
Setting up the Web Admin Tool in LDAP 6.x to communicate via SSL
查看>>
SQL好习惯:编写支持可搜索的SQL
查看>>