package com.android.haven.contact;
import java.util.List;
import com.android.haven.adapter.ContactAdapter;
import com.android.haven.adapter.ContactEntity;
import com.android.haven.listener.ContactListener;
import com.android.haven.service.ContactService;
import android.app.ProgressDialog;
import android.app.TabActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.Toast;
public class ContactManagerActvity extends TabActivity {
public TabHost myTabHost;
private ListView phoneListView;
private ListView simListView;
public ContactAdapter phoneAdapter;
public ContactAdapter simAdapter;
public List<ContactEntity> phoneList;
public List<ContactEntity> simList;
public boolean canDelete = true;
private ProgressDialog dialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.contact_manager);
myTabHost = getTabHost();
myTabHost.addTab(myTabHost
.newTabSpec("0")
.setContent(new TabHost.TabContentFactory() {
public View createTabContent(String tag) {
return ContactManagerActvity.this
.findViewById(R.id.phone_contacts);
}
})
.setIndicator(
"手机联系人",
ContactManagerActvity.this.getResources().getDrawable(
R.drawable.phone)));
myTabHost.addTab(myTabHost
.newTabSpec("1")
.setContent(new TabHost.TabContentFactory() {
public View createTabContent(String tag) {
return ContactManagerActvity.this
.findViewById(R.id.sim_contacts);
}
})
.setIndicator(
"SIM联系人",
ContactManagerActvity.this.getResources().getDrawable(
R.drawable.sim)));
TabWidget widget = getTabWidget();
View v0 = widget.getChildAt(0);
View v1 = widget.getChildAt(1);
v0.getLayoutParams().height = 58;
v1.getLayoutParams().height = 58;
phoneListView = (ListView) findViewById(R.id.phone_contacts);
simListView = (ListView) findViewById(R.id.sim_contacts);
phoneListView.setOnItemClickListener(ContactListener.instance().new MyListItemOnClickListener(this));
simListView.setOnItemClickListener(ContactListener.instance().new MyListItemOnClickListener(this));
phoneList = ContactService.instance().loadInfoFromPhone(this,0);
phoneAdapter = new ContactAdapter(ContactManagerActvity.this, phoneList);
phoneListView.setAdapter(phoneAdapter);
simList = ContactService.instance().loadInfoFromPhone(this,1);
simAdapter = new ContactAdapter(ContactManagerActvity.this, simList);
simListView.setAdapter(simAdapter);
myTabHost.setCurrentTab(0);
myTabHost.setCurrentTab(1);
myTabHost.setCurrentTab(0);
dialog = new ProgressDialog(this);
dialog.setMessage("删除中!");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 1, 0, "选择全部").setIcon(
getResources().getDrawable(R.drawable.choose_all));
menu.add(0, 2, 0, "取消选中").setIcon(
getResources().getDrawable(R.drawable.cancel_all));
menu.add(0, 3, 0, "删除选中").setIcon(
getResources().getDrawable(R.drawable.delete));
menu.add(0, 4, 0, "推出系统").setIcon(
getResources().getDrawable(R.drawable.exit));
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
ContactService.instance().checkAll(this);
break;
case 2:
ContactService.instance().cancelAll(this);
break;
case 3:
dialog.show();
ContactService.instance().deleteSelectedItems(this);
break;
case 4:
this.finish();
System.exit(0);
break;
default:
break;
}
return true;
}
public Handler myHandler = new Handler(){
@Override
public void handleMessage(Message msg){
ContactEntity entity = null;
Intent intent = null;
Uri uri = null;
switch(msg.what){
case 0:
phoneAdapter.notifyDataSetChanged();
canDelete = true;
break;
case 1:
simAdapter.notifyDataSetChanged();
canDelete = true;
break;
case 2:
dialog.cancel();
Toast.makeText(getApplicationContext(), "删除操作结束!", Toast.LENGTH_LONG).show();
break;
case 10:
if(myTabHost.getCurrentTab() == 0)
entity = phoneList.get(msg.arg1);
else
entity = simList.get(msg.arg1);
if(entity.getPhoneNum() == null || entity.getPhoneNum().equals("") ){
Toast.makeText(ContactManagerActvity.this, "号码格式错误!", Toast.LENGTH_LONG).show();
ContactListener.instance().dialog.cancel();
return;
}
uri = Uri.parse("tel:"+entity.getPhoneNum());
intent = new Intent(Intent.ACTION_CALL,uri);
startActivity(intent);
ContactListener.instance().dialog.cancel();
break;
case 11:
if(myTabHost.getCurrentTab() == 0)
entity = phoneList.get(msg.arg1);
else
entity = simList.get(msg.arg1);
if(entity.getPhoneNum() == null || entity.getPhoneNum().equals("")){
Toast.makeText(ContactManagerActvity.this, "号码格式错误!", Toast.LENGTH_LONG).show();
ContactListener.instance().dialog.cancel();
return;
}
uri = Uri.parse("smsto:"+entity.getPhoneNum());
intent = new Intent(Intent.ACTION_SENDTO,uri);
startActivity(intent);
ContactListener.instance().dialog.cancel();
break;
case 12:
if(ContactService.instance().deleteSelectedItem(ContactManagerActvity.this, msg.arg1) == 1)
Toast.makeText(ContactManagerActvity.this, "删除成功!", Toast.LENGTH_LONG).show();
ContactListener.instance().dialog.cancel();
break;
case 13:
ContactListener.instance().dialog.cancel();
break;
default:
break;
}
}
};
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Android 一个批量删除联系人的Demo.zip项目安卓应用源码下载Android 一个批量删除联系人的Demo.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
资源推荐
资源详情
资源评论
收起资源包目录
Android 一个批量删除联系人的Demo.zip (58个子文件)
Android 一个批量删除联系人的Demo
Android 一个批量删除联系人的Demo
1-120QP22T20-L.png 21KB
一个批量删除联系人的Demo
.project 850B
default.properties 364B
bin
ContactManager.apk 53KB
com
android
haven
contact
R$string.class 563B
ContactManagerActvity.class 6KB
R$layout.class 531B
R$drawable.class 895B
ContactManagerActvity$3.class 971B
R.class 580B
ContactManagerActvity$1.class 3KB
R$attr.class 361B
ContactManagerActvity$2.class 971B
R$id.class 646B
listener
ContactListener$MyGridItemOnClickListener.class 2KB
ContactListener$MyListItemOnClickListener.class 4KB
ContactListener.class 777B
adapter
ContactAdapter$1.class 1KB
ContactEntity.class 2KB
ContactAdapter.class 3KB
GridAdapter.class 2KB
service
ContactService$1.class 3KB
ContactService.class 5KB
resources.ap_ 42KB
classes.dex 19KB
AndroidManifest.xml 922B
src
com
android
haven
contact
ContactManagerActvity.java 6KB
listener
ContactListener.java 3KB
adapter
ContactEntity.java 2KB
ContactAdapter.java 2KB
GridAdapter.java 2KB
service
ContactService.java 5KB
res
values
strings.xml 374B
layout
contact_row.xml 2KB
grid_item.xml 673B
contact_manager.xml 1KB
gridview_menu.xml 791B
drawable-ldpi
icon.png 5KB
drawable-hdpi
icon.png 5KB
drawable
bg.png 5KB
sms_popup.png 5KB
sim.png 5KB
line_between.png 423B
cancel_all.png 1KB
exit.png 1KB
sms.png 3KB
add_popup.png 2KB
choose_all.png 2KB
bg_cal_card.png 7KB
call_popup.png 2KB
cancel_popup.png 2KB
delete.png 5KB
popup_bg.png 3KB
icon.png 5KB
phone.png 5KB
drawable-mdpi
icon.png 5KB
.classpath 280B
gen
com
android
haven
contact
R.java 2KB
assets
共 58 条
- 1
资源评论
yxkfw
- 粉丝: 80
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- new_bird_c-c语言入门
- christmasTree-圣诞树html网页代码
- working-shell脚本入门——流程控制
- hadoop_install-sqoop数据导入
- ThinkCMF-mysql安装
- BigData-Notes-sqoop的安装与配置
- C语言-leetcode题解之28-implement-strstr.c
- C语言-leetcode题解之27-remove-element.c
- C语言-leetcode题解之26-remove-duplicates-from-sorted-array.c
- C语言-leetcode题解之24-swap-nodes-in-pairs.c
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功