可变位置高级弹窗
2023-01-24 09:16:15 最后更新
//Code By kbz
mian.iyu
样1:
cls("android.content.DialogInterface$OnClickListener", 事件类)
javacb(事件, 事件类)
{
s qun=178772968
ss("mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+qun+"&card_type=group&source=qrcode",joinqq)
sit(a,"action", "android.intent.action.VIEW")
sit(a,"data",joinqq)
uit(a, "chooser", "选择QQ")
}
javacb(事件2, 事件类)
{
tw("wee")
}
fn 弹窗.构建(null,"AlertDialog","这是一个AlertDialog!",true)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮1","确定",事件)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮2","关闭",事件2)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮3","我只是凑个数",null)
fn 弹窗.显示(sss.弹窗对象)

样2:
cls("android.content.DialogInterface$OnClickListener", 事件类)
javacb(事件, 事件类)
{
s qun=178772968
ss("mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+qun+"&card_type=group&source=qrcode",joinqq)
sit(a,"action", "android.intent.action.VIEW")
sit(a,"data",joinqq)
uit(a, "chooser", "选择QQ")
}
fn 弹窗.构建(null,"AlertDialog","界面.iyu",null)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮1","确定",事件)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮2","关闭",null)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮3","我只是凑个数",null)
fn 弹窗.显示(sss.弹窗对象)
gvs(sss.弹窗布局,界面.3,文本)
//gvs用法请看手册
//获取弹窗中的控件3
us(文本,"text","测试OK")
fn 弹窗.设置位置(sss.弹窗对象,"BOTTOM")
zdp(220,高度)
zdp(330,宽度)
fn 弹窗.设置样式(sss.弹窗对象,宽度,高度,50,150)
fn 弹窗.取标题(sss.弹窗对象)
us(sss.标题,"textcolor","#E91E63")
fn 弹窗.取消息(sss.弹窗对象)
us(sss.消息,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_POSITIVE")
us(sss.按钮,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_NEGATIVE")
us(sss.按钮,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_NEUTRAL")
us(sss.按钮,"textcolor","#E91E63")

样3:
cls("android.content.DialogInterface$OnClickListener", 事件类)
javacb(事件, 事件类)
{
s qun=178772968
ss("mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+qun+"&card_type=group&source=qrcode",joinqq)
sit(a,"action", "android.intent.action.VIEW")
sit(a,"data",joinqq)
uit(a, "chooser", "选择QQ")
}
javacb(事件2, 事件类)
{
s qun=178772968
ss("mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+qun+"&card_type=group&source=qrcode",joinqq)
sit(a,"action", "android.intent.action.VIEW")
sit(a,"data",joinqq)
uit(a, "chooser", "选择QQ")
}
fn 弹窗.构建(null,"AlertDialog","这是一个AlertDialog!",null)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮1","确定",事件)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮2","关闭",事件2)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮3","我只是凑个数",null)
fn 弹窗.显示(sss.弹窗对象)

fn 弹窗.设置位置(sss.弹窗对象,"BOTTOM")
zdp(180,高度)
zdp(300,宽度)
fn 弹窗.设置样式(sss.弹窗对象,宽度,高度,50,150)

fn 弹窗.取标题(sss.弹窗对象)
us(sss.标题,"textcolor","#E91E63")
fn 弹窗.取消息(sss.弹窗对象)
us(sss.消息,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_POSITIVE")
us(sss.按钮,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_NEGATIVE")
us(sss.按钮,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_NEUTRAL")
us(sss.按钮,"textcolor","#E91E63")

样4(动态加控件):
nvw(null, null, "线性布局", "width=-1\nheight=-1", linear)
nvw(null, linear,"编辑框","width=-1\nheight=-1\ntext=??????\nlayout_marginleft=20dp\nlayout_marginright=20dp",textid)

fn 着色.控件着色(textid,"#35f2b5")

cls("android.content.DialogInterface$OnClickListener", 事件类)
javacb(事件, 事件类)
{
s qun=178772968
ss("mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+qun+"&card_type=group&source=qrcode",joinqq)
sit(a,"action", "android.intent.action.VIEW")
sit(a,"data",joinqq)
uit(a, "chooser", "选择QQ")
}
javacb(事件2, 事件类)
{
  ug(textid,"text",a)
  tw(a)
}

fn 弹窗.构建(null,"AlertDialog",linear,null)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮1","确定",事件)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮2","关闭",事件2)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮3","我只是凑个数",null)
fn 弹窗.显示(sss.弹窗对象)
fn 弹窗.取标题(sss.弹窗对象)
us(sss.标题,"textcolor","#E91E63")
fn 弹窗.取消息(sss.弹窗对象)
us(sss.消息,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_POSITIVE")
us(sss.按钮,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_NEGATIVE")
us(sss.按钮,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_NEUTRAL")
us(sss.按钮,"textcolor","#E91E63")

样5(动态加控件并给事件):
cls("android.content.DialogInterface$OnClickListener", 事件类)
javacb(事件, 事件类)
{
s qun=178772968
ss("mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+qun+"&card_type=group&source=qrcode",joinqq)
sit(a,"action", "android.intent.action.VIEW")
sit(a,"data",joinqq)
uit(a, "chooser", "选择QQ")
}
javacb(事件2, 事件类)
{
s qun=178772968
ss("mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+qun+"&card_type=group&source=qrcode",joinqq)
sit(a,"action", "android.intent.action.VIEW")
sit(a,"data",joinqq)
uit(a, "chooser", "选择QQ")
}
//nvw(null, null, "线性布局", "", linear)
//nvw(null, null,"编辑框","width=-1\nheight=-2\ntext=??????\nlayout_marginleft=20dp\nlayout_marginright=20dp",textid)

nvw(null, null, "线性布局", "width=-1\nheight=-1\norientation=vertical", linear)
nvw(null, linear,"按钮","width=-1\nheight=-1\ntext=www\nbackground=through\npaddingleft=30dp\ngravity=left|center_vertical",b1)
nvw(null, linear,"按钮","width=-1\nheight=-1\ntext=www\nlayout_marginleft=20dp\nlayout_marginright=20dp",b2)
nvw(null, linear,"按钮","width=-1\nheight=-1\ntext=www\nlayout_marginleft=20dp\nlayout_marginright=20dp",b3)
ssj(b1,"clicki")
{
  fn 弹窗.关闭(sss.弹窗对象)
}

fn 弹窗.构建(null,"AlertDialog",linear,null)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮1","确定",事件)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮2","关闭",事件2)
fn 弹窗.设置按钮(sss.弹窗对象,"按钮3","我只是凑个数",null)
fn 弹窗.显示(sss.弹窗对象)
fn 弹窗.取标题(sss.弹窗对象)
us(sss.标题,"textcolor","#E91E63")
fn 弹窗.取消息(sss.弹窗对象)
us(sss.消息,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_POSITIVE")
us(sss.按钮,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_NEGATIVE")
us(sss.按钮,"textcolor","#E91E63")
fn 弹窗.取按钮(sss.弹窗对象,"BUTTON_NEUTRAL")
us(sss.按钮,"textcolor","#E91E63")

//--关闭弹窗:
fn 弹窗.关闭(sss.弹窗对象)

//--------------------下方代码放到[弹窗.myu]里面,没有就新建一个,否则上方代码失效---------------------------
/.
传入数据 弹窗图标位置,弹窗标题,弹窗内容,返回键是否可以关闭
注意:弹窗内容可以写界面名!
直接以这个界面做为界面内容
调用此方法后,会生成一个全局变量 弹窗对象
为弹窗的Builder对象
当界面内容为界面名时,还会生成一个全局变量 弹窗布局
为弹窗里的View对象
通过gvs可以获取里面的控件
./
fn 构建(图标,标题,内容,关闭)
syso(内容)
javanew(弹窗对象,"android.app.AlertDialog$Builder", "android.content.Context", activity)
f(图标!=null)
{
  sbp(图标,图标)
  java(null,弹窗对象,"android.app.AlertDialog$Builder.setIcon","android.graphics.drawable.Drawable",图标)
}
f(标题!=null)
{
  java(null,弹窗对象,"android.app.AlertDialog$Builder.setTitle","CharSequence",标题)
}
f(内容*?".iyu"||内容*?"ijs"||内容*?"ijava")
{
  javanew(布局参数,"android.widget.LinearLayout$LayoutParams","int",-1,"int",-1)
  javanew(线性布局,"android.widget.LinearLayout","Context",activity)
  java(null,线性布局,"android.view.View.setLayoutParams","android.view.ViewGroup$LayoutParams",布局参数)
  java(null,线性布局,"android.widget.LinearLayout.setOrientation","int",1)
  addv(线性布局,内容)
  java(null,弹窗对象,"android.app.AlertDialog$Builder.setView","android.view.View",线性布局)
  sss 弹窗布局=线性布局
}
f(内容?"android.widget")
{
  javanew(布局参数,"android.widget.LinearLayout$LayoutParams","int",-1,"int",-1)
  javanew(线性布局,"android.widget.LinearLayout","Context",activity)
  java(null,线性布局,"android.view.View.setLayoutParams","android.view.ViewGroup$LayoutParams",布局参数)
  java(null,线性布局,"android.widget.LinearLayout.setOrientation","int",1)

  //nvw(null, null, "线性布局", "width=-1\nheight=-1", 线性布局)
  //nvw(null, null,"编辑框","width=-1\nheight=-2\ntext=??????\nlayout_marginleft=20dp\nlayout_marginright=20dp",textid)
  nvw(内容,线性布局)
  java(null,弹窗对象,"android.app.AlertDialog$Builder.setView","android.view.View",线性布局)
  sss 弹窗布局=线性布局
}
else
{
  java(null, 弹窗对象,"android.app.AlertDialog$Builder.setMessage","CharSequence",内容)
}
f(关闭)
{
  java(null, 弹窗对象,"android.app.AlertDialog$Builder.setCancelable", "boolean", false)
}
sss 弹窗对象=弹窗对象
end fn
/.
传入数据 弹窗对象,按钮位置,按钮文字,按钮点击事件
注意,按钮位置按从右到左分别为
按钮1,按钮2,按钮3
按钮的点击事件可以传null
./
fn 设置按钮(弹窗对象,按钮,文字,事件)
cls("android.content.DialogInterface$OnClickListener", 事件类)
f(按钮=="按钮1")
{
  javax(null, 弹窗对象, "android.app.AlertDialog$Builder", "setPositiveButton", "CharSequence",文字, 事件类, 事件)
}
else f(按钮=="按钮2")
{
  javax(null, 弹窗对象, "android.app.AlertDialog$Builder", "setNegativeButton", "CharSequence",文字, 事件类, 事件)
}
else f(按钮=="按钮3")
{
  javax(null, 弹窗对象, "android.app.AlertDialog$Builder", "setNeutralButton", "CharSequence",文字, 事件类, 事件)
}
end fn
/.
传入弹窗对象即可
调用此方法后,会生成一个全局变量
为弹窗的对象
./
/.
.注意!,
.此方法之后的所有方法必须在调用了此方法之后在调用
.否则报错!
./
fn 显示(弹窗对象)
java(弹窗对象,弹窗对象,"android.app.AlertDialog$Builder.create")
java(null,弹窗对象,"android.app.Dialog.show")
sss 弹窗对象=弹窗对象
end fn
//传入弹窗对象即可关闭弹窗
fn 关闭(弹窗对象)
java(null,弹窗对象,"android.app.Dialog.dismiss")
end fn
//传入弹窗对象
//生成一个全局变量 标题
//可以使用us对其进行各种设置
fn 取标题(弹窗对象)
javags(对话框,弹窗对象,"android.app.AlertDialog","mAlert")
javags(sss.标题,对话框,"com.android.internal.app.AlertController","mTitleView")
end fn
//传入弹窗对象
//生成一个全局变量 消息
//可以使用us对其进行各种设置
fn 取消息(弹窗对象)
javags(对话框,弹窗对象,"android.app.AlertDialog","mAlert")
javags(sss.消息,对话框,"com.android.internal.app.AlertController","mMessageView")
end fn
//传入 弹窗对象,标识
//标识数据如下
//左边按钮BUTTON_NEUTRAL
//中间按钮BUTTON_NEGATIVE
//右边按钮BUTTON_POSITIVE
//生成一个全局变量 按钮
//可以使用us对其进行各种设置
fn 取按钮(弹窗对象,标识)
javags(标识,null,"android.content.DialogInterface",标识)
javax(sss.按钮, 弹窗对象,"android.app.AlertDialog","getButton", "int", 标识)
end fn
//传入数据 弹窗对象,弹窗位置
//弹窗位置数据如下
//CENTER中间
//BOTTOM底部
//LEFT左边
//RIGHT右边
//TOP顶部
fn 设置位置(弹窗对象,位置)
java(window,弹窗对象,"android.app.Dialog.getWindow")
javags(位置,null,"android.view.Gravity",位置)
java(null,window,"android.view.Window.setGravity","int",位置)
end fn
//传入 弹窗对象,弹窗的宽度,弹窗的高度,弹窗在x上的偏移量,弹窗在y上的偏移量
//宽度和高度的单位为px
//可以使用zdp把dp转换为px后再传入
fn 设置样式(弹窗对象,宽度,高度,x,y)
java(window,弹窗对象,"android.app.Dialog.getWindow")
cls("android.view.WindowManager$LayoutParams",cls_lp)
java(lp,window,"android.view.Window.getAttributes")
javass(null,lp,"android.view.ViewGroup$LayoutParams","width",宽度)
javass(null,lp,"android.view.ViewGroup$LayoutParams","height",高度)
javass(null,lp,"android.view.WindowManager$LayoutParams","y",y)
javass(null,lp,"android.view.WindowManager$LayoutParams","x",x)
java(null,window,"android.view.Window.setAttributes",cls_lp,lp)
end fn