/*
* function:传入参数创建自定义的显示Dialog
* title:dialog的消息体
* bt1:按钮上的text
* bt2:按钮上的text
* author:dy
* time:12-08-14
*/
private Dialog createMyDialog(String title,String bt1,String bt2) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setMessage(title)
.setCancelable(false)
.setPositiveButton(bt1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
DialogActivity.this.finish();
}
})
.setNegativeButton(bt2, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
}
});
return dialogBuilder.create();
}
/* * function:自定义notification函数 * icon:图标索引 * original:消息名称 * notificationTitile:具体消息的Titile * notificationText:具体消息的内容 * author:dy * time:12-08-14 */private void dyNotification(int icon, String original,String notificationTitle, String notificationText) {//定义IDfinal int ID = 1;//创建Intent对象和PendingIntent对象Intent intent = new Intent(this,aNotificationActivity.class);PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);//获取MOtificationManager对象NotificationManager nm = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);//创建Notification对象Notification n = new Notification(icon,original,System.currentTimeMillis());//设置消息事件n.setLatestEventInfo(getApplicationContext(), notificationTitle, notificationText, contentIntent);//将notification添加到NotificationManager中nm.notify(ID, n);}
/*
* function:弹出的消息对话框中的内容是list显示的
* title:dialog的title
* items:一个字符数组,其中的每一项就被显示在list中
* author:dy
* time:12-08-14
*
*/
private Dialog createListDialog(String title,final CharSequence[] items) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle(title);
dialogBuilder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
// TODO Auto-generated method stub
//Toast.makeText(getApplication(), items[item], Toast.LENGTH_LONG).show();
//to dong somethings
}
});
return dialogBuilder.create();
}
/*
* function:弹出的消息对话框中的内容是一checkBoxes的形式显示的
* title:dialog的title
* items:一个字符数组,其中的每一项就被显示在checkBoxes选项中
* author:dy
* time:12-08-14
*
*/
private Dialog createCheckBoxesDialog(String title,final CharSequence[] items) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle(title);
dialogBuilder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
// TODO Auto-generated method stub
//Toast.makeText(getApplication(), items[item], Toast.LENGTH_LONG).show();
//to do somethings
}
});
return dialogBuilder.create();
}