草庐IT

AlertDialog

全部标签

NextJS开发:封装shadcn/ui中的AlertDialog确认对话框

shadcn/ui很灵活可以方便的自己修改class样式,但是仅仅一个确认删除弹窗,需要拷贝太多代码和导入太多包,重复的代码量太多,不利于代码维护。所以进一步封装以符合项目中使用。封装cx-alert-dialog.tsximport{AlertDialog,AlertDialogAction,AlertDialogCancel,AlertDialogContent,AlertDialogDescription,AlertDialogFooter,AlertDialogHeader,AlertDialogTitle,AlertDialogTrigger,}from"@/components/u

【Android入门到项目实战--3.1】—— 七种常用控件的使用(TextView、Button、EditText、ImageView、ProgressBar、AlertDialog等)

目录一、常用的控件1、TextView2、Button3、EditText4、ImageView 5、ProgressBar1)如何让加载条在加载完成时消失?2)如何修改进度条样式?6、AlertDialog7、ProgressDialog本篇主要讲解Android的常用控件。一、常用的控件1、TextView       TextView控件用于在界面上显示一段文本信息。下面尝试实现。XML布局文件代码如下:               android:layout_width、android:layout_height这两个属性所有控件都有,可选值有:match_parent和wrap_p

Android:AlertDialog 仅在第二次单击任何按钮后关闭

我有一个带有输入字段和两个按钮(还原、保存)的警告对话框。当我点击手机上的“后退”按钮时,我希望弹出另一个确认对话框询问:“你确定要完成吗?”。所以它看起来像这样:publicvoidshowNewItemDialog(finalint...position){LayoutInflaterli=LayoutInflater.from(HostActivity.this);ViewpromptsView=li.inflate(R.layout.item_dialog,null);AlertDialog.BuilderalertDialogBuilder=newAlertDialog.Bu

android - 在 AndroidTestCase 中访问 AlertDialog

我正在使用ActivityInstrumentationTestCase2在我的GUI上进行自动黑盒测试。有没有办法点击一个对话框,或者在单元测试中获取属于该对话框的View?我能想出的唯一方法是保留对对话框的引用并让我的Activity实现一个getter方法让测试用例访问对话框。有没有不需要更改生产代码的更好方法? 最佳答案 是的,有一种更好的方法可以将AlertDialogs暴露给您的自动化代码,但您必须在生产代码中这样做。这是值得的,因为它会让你的生活更轻松。让我解释。您可以将AlertDialogs分配给WeakHashM

android - onPostExecute 中的 AlertDialog 未显示

我正在尝试在AsyncTask的onPostExecute方法上显示一个对话框@OverrideprotectedvoidonPostExecute(HttpResponseresponse){if(response==null){Log.d(TAG,"onPostExecute,response==null");AlertDialog.Builderbuilder=newAlertDialog.Builder(ConfirmPhoneNoCode.this);builder.setMessage("Areyousureyouwanttoexit?").setCancelable(fa

java - 单击 onOptionsItemSelected 中的 AlertDialog 中的按钮会使模拟器崩溃

我的主要问题是:无论如何我都可以从onOptionsItemSelected()内部触发AlertDialog而不会在我按下对话框上的按钮时使我的模拟器崩溃?为此,我在整个互联网上进行了搜索,但我发现每个人都在说同样的话,但即使我复制并粘贴他们的代码,我也会遇到同样的错误。所以我会尽量解释我的情况。这是一个非常简单的AlertDialog示例:AlertDialog.BuilderalertDialogBuilder=newAlertDialog.Builder(this).setTitle("YourTitle").setMessage("Clickyestoexit!").setC

android - 从自定义 ListAdapter 创建和显示 AlertDialog

我正在实现一个自定义ListAdapter,它使用不同的列表项布局来显示一些项目。从那个自定义ListAdapter,我实际上想在单击特定按钮时显示一个AlertDialog。我实现了onCreateDialog(int)方法,我正在尝试使用showDialog(int)来显示对话框。但是对话框不会显示在Activity中。这是我的自定义列表适配器文件importandroid.app.Activity;importandroid.app.AlertDialog;importandroid.app.Dialog;importandroid.content.DialogInterface

android - 如何从 alertDialog 设置 EditText 的行数

我需要将alertDialog中的EditText的行数设置为1。我输入了input.setLines(1)但它不起作用。它让我输入不止一行,但我只看到最后一行。那么,解决这个问题的方法是什么?这是我的代码:finalAlertDialog.Builderalert=newAlertDialog.Builder(this);alert.setTitle(data);finalEditTextinput=newEditText(this);InputFilter[]FilterArray=newInputFilter[1];FilterArray[0]=newInputFilter.Le

android - 如何从 AlertDialog 中的 XML 布局获取对 TextView 的引用?

我在获取有关TextView、SeekBar和其他小部件的引用时遇到了一个奇怪的问题。我的AlertDialog看起来像这样:publicclassLineDialogextendsAlertDialog{privatestaticSeekBarseekBar1,seekBar2,seekBar3;privatestaticTextViewtextView1,textview2,textView3;protectedLineDialog(finalContextcontext,finalDrawViewdrawView){super(context);LayoutInflaterinf

android:如何从数据库中为 AlertDialog 设置图标?

所以我正在向AlertDialog展示这样的内容:newAlertDialog.Builder(context).setMessage(message).setTitle(title).setCancelable(true).setIcon(R.drawable.ic_launcher)//seticon//morecode是否可以使用setIcon从数据库获取图标,例如联系人照片:DatabaseHelperdb=newDatabaseHelper(context);Cursorcsr=db.getSpecialContact(number);csr.moveToFirst();St