Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> Android開發 >> 關於android開發 >> android xml的生成與解析,androidxml解析

android xml的生成與解析,androidxml解析

編輯:關於android開發

android xml的生成與解析,androidxml解析


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<SmsBean> getAllSms() {
        ArrayList<SmsBean> arrayList = new ArrayList<SmsBean>();
        
        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;
    
    
}

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved