編輯:關於android開發
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; }
Android群英傳-拼圖游戲puzzle-6點吐槽 一、緣由 經常寫文章,混了一些C幣。最近在深入學習Android應用開發,就從商城裡買了一本《Android群英
(轉)最強Android模擬器genymotion的安裝與配置,androidgenymotion Android開發人員都知道,原生的模擬器啟動比較慢,操作起來也不流暢
基於PinnedSectionListView實現聯系人通訊錄並且點擊打電話,手機通訊錄聯系人恢復PinnedSectionListView具體下載地址、使用方法和注意事
android開發游記:meterial design 5.0 新增控件介紹及使用方法 Android 5.0 Lollipop 是迄今為止最重大的一次發布,因為 mat