AlertDialog && PopupWindow[已解决]
来源:互联网 发布:淘宝上解id锁被骗了 编辑:程序博客网 时间:2024/05/16 05:07
AlertDialog
AlertDialog aDialog;
setAlertDialog();
aDialog.show();
protected void setAlertDialog() {
// TODO Auto-generated method stub
final String[] items = getResources().getStringArray(R.array.alarm_type_item);
AlertDialog.Builder ab = new AlertDialog.Builder(this)
.setTitle("请点击选择").setItems(items, multiClick);
aDialog = ab.create();
}
private DialogInterface.OnClickListener multiClick = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "第" + (which) + "项选中",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent();
if (which == 0)
{
intent.setClass(MainActivity.this,AddQuickNormalAlarm.class);
MainActivity.this.startActivity(intent);
}
}
};
转:
ab.setTitle("HelloAlert").setMessage("Warning: its Alert Demo!").setIcon(R.drawable.robot);
- builder.setIcon(R.drawable.icon);
- 53. builder.setTitle("Title");
- 54. builder.setMessage("Message");
- 55. builder.setPositiveButton("Button1",
- 56. new DialogInterface.OnClickListener() {
- 57. public void onClick(DialogInterface dialog, int whichButton) {
- 58. setTitle("点击了对话框上的Button1");
- 59. }
- 60. });
- 61. builder.setNeutralButton("Button2",
- 62. new DialogInterface.OnClickListener() {
- 63. public void onClick(DialogInterface dialog, int whichButton) {
- 64. setTitle("点击了对话框上的Button2");
- 65. }
- 66. });
- 67. builder.setNegativeButton("Button3",
- 68. new DialogInterface.OnClickListener() {
- 69. public void onClick(DialogInterface dialog, int whichButton) {
- 70. setTitle("点击了对话框上的Button3");
- 71. }
- 72. });
转
函数简介showAsDropDown(View anchor)相对某个控件的位置(正左下方),无偏移showAsDropDown(View anchor, int xoff, int yoff)相对某个控件的位置,有偏移showAtLocation(View parent, int gravity, int x,inty)父容器容器相对位置,例如正中央Gravity.CENTER,下方Gravity.BOTTOM等
PopupWindow pWindow;
setPopupWindow();
pWindow.showAsDropDown(v);
private void setPopupWindow() {
if (null != pWindow) {
pWindow.dismiss();
return;
} else
initPopuptWindow();
}
protected void initPopuptWindow() {
// TODO Auto-generated method stub
// 获取自定义布局文件pop.xml的视图
View popupWindow_view = getLayoutInflater().inflate(R.layout.appendix,
null, false);
// 创建PopupWindow实例,200,150分别是宽度和高度
pWindow = new PopupWindow(popupWindow_view, 50, 150, true);
// 设置动画效果
// pWindow.setAnimationStyle(R.style.AnimationFade);
// 点击其他地方消失
popupWindow_view.setOnTouchListener(new OnTouchListener() {
// @Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if (pWindow != null && pWindow.isShowing()) {
pWindow.dismiss();
pWindow = null;
}
return false;
}
});
}
0 0
- AlertDialog && PopupWindow[已解决]
- PopupWindow,AlertDialog
- PopupWindow和AlertDialog区别
- 【Android】AlertDialog PopupWindow对话框
- PopupWindow和AlertDialog区别
- PopupWindow和AlertDialog区别
- PopupWindow与AlertDialog区别
- 自定义PopupWindow和AlertDialog
- PopupWindow和AlertDialog区别
- PopupWindow和AlertDialog区别
- AlertDialog跟PopupWindow对话框
- PopupWindow和AlertDialog区别
- Toast,popupWindow,AlertDialog
- AlertDialog 与 PopupWindow的 区别
- android PopupWindow和AlertDialog区别
- PopupWindow与AlertDialog的使用
- PopupWindow和AlertDialog的区别
- PopupWindow+AlertDialog+xrecycleview代码片
- rm删除破折号开头的文件或目录
- onClickListener 错误【已解决】
- android 系统时间的获取与显示 【已解决】
- C++手记--变量和基本类型
- 调用系统自带录音【已解决】
- AlertDialog && PopupWindow[已解决]
- smarty
- 腾讯马化腾的万字演讲-微信和手Q的交锋
- MATLAB-PACKAGE
- H?lder\'s inequality
- 三星Note3的S Pen随剪随贴功能怎么用
- 【弱弱的c#】構造函數
- 【弱弱的c#】ERROR:可訪問性不一致
- 【弱弱的c#】switch-case
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
女式风衣中长款
中长款大衣
中长款羽绒服
长是
蕾丝中长款打底衫
长轴长
中老年女式风衣中长款
中长款皮衣
女款棉服中长款
长5
女士真皮皮衣中长款
中长款卫衣
卫衣中长款
中长款包裙
中长款风衣女
长不长
女士中长款针织开衫
中长款女式针织衫
,长
中长款打底裙
中长款衬衣
秋装新款女装中长款
大码羊绒大衣中长款
中长款马甲
长1
中长款西装怎么搭配
羊毛开衫中长款
中长款呢子大衣
毛呢中长款
中长款黑色打底衫
针织衫中长款
女式中长款真皮皮衣
中长发小卷
中长款蕾丝裙
秋衣中长款
品牌毛呢大衣中长款
宽松打底衫中长款
中长款皮衣搭配
男童羽绒服中长款
中长款毛衣针织开衫
韩版中长款