草庐IT

AlertDialog_multiChoiceItemLayout

全部标签

android - 具有自定义布局和 EditText 的 AlertDialog.Builder;无法访问 View

我正在尝试使用EditText对象创建警报对话框。我需要以编程方式设置EditText的初始文本。这就是我所拥有的。AlertDialog.BuilderdialogBuilder=newAlertDialog.Builder(this);//...IrrelevantcodeforcustomizingthebuttonsandtitleAlertDialogalertDialog=dialogBuilder.create();LayoutInflaterinflater=this.getLayoutInflater();alertDialog.setContentView(infl

android - 在屏幕的任意位置显示 AlertDialog

当我们在android中显示AlertDialog时,它会显示在屏幕中央。有什么办法可以改变位置吗? 最佳答案 在各种帖子中搜索后,我找到了解决方案。代码贴在下面:privateCharSequence[]items={"SetasRingtone","SetasAlarm"};AlertDialog.Builderbuilder=newAlertDialog.Builder(this);builder.setItems(items,newDialogInterface.OnClickListener(){publicvoidonC

android - 如何实现自定义的 AlertDialog View

在AndroiddocsonAlertDialog,它提供了以下说明和示例,用于在AlertDialog中设置自定义View:Ifyouwanttodisplayamorecomplexview,lookuptheFrameLayoutcalled"body"andaddyourviewtoit:FrameLayoutfl=(FrameLayout)findViewById(R.id.body);fl.add(myView,newLayoutParams(FILL_PARENT,WRAP_CONTENT));首先,很明显add()是一个错字,应该是addView()。我对使用R.id.

android - "Avoid passing null as the view root"膨胀 View 以供 AlertDialog 使用时发出警告

我收到lint警告,在使用null作为parent膨胀View时避免将null作为View根传递,例如:LayoutInflater.from(context).inflate(R.layout.dialog_edit,null);但是,View将用作AlertDialog的内容,在AlertDialog.Builder上使用setView,所以我不这样做不知道应该作为parent传递什么。你认为在这种情况下parent应该是什么? 最佳答案 使用此代码在没有警告的情况下扩展对话框View:View.inflate(context,

android - 当使用带有 EditText 的 AlertDialog.Builder 时,软键盘不会弹出

我正在使用AlertDialog.Builder来创建一个输入框,使用EditText作为输入法。很遗憾,尽管EditText处于焦点位置,但软键盘没有弹出,除非您再次明确触摸它。有没有办法强制它弹出?我在(AlertDialog.Builder).show();之后尝试了以下操作,但没有成功。InputMethodManagermgr=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);mgr.showSoftInput(input,InputMethodManager.SHOW_FORCED);有人可

android - 如何从字符串资源中获取 AlertDialog 中的可点击超链接?

我想要完成的是在AlertDialog显示的消息文本中添加可点击的超链接。.而AlertDialog实现愉快地为任何超链接(在传递给的字符串资源中使用Builder.setMessage定义)加下划线和着色,前提是链接不会变为可点击。我目前使用的代码如下:newAlertDialog.Builder(MainActivity.this).setTitle(R.string.Title_About).setMessage(getResources().getText(R.string.about)).setPositiveButton(android.R.string.ok,null).

android - 如何使用 appCompat 22.1 及更高版本中的新 AlertDialog 并为其设置样式

我正在尝试从默认的androidAlertDialog迁移到appCompat-22.1中包含的新版本到目前为止,我了解您只需导入android.support.v7.app.AlertDialog包即可使用它。但是我该如何设计呢?例如更改正/负按钮颜色、标题颜色、消息颜色和背景颜色? 最佳答案 在创建AlertDialog时,您可以设置要使用的主题。示例-创建对话框AlertDialog.Builderbuilder=newAlertDialog.Builder(this,R.style.MyAlertDialogStyle);b

android - 如何更改 AlertDialog 的主题

我想知道是否有人可以帮助我。我正在尝试创建一个自定义AlertDialog。为了做到这一点,我在styles.xml中添加了以下代码行@drawable/color_panel_backgroundcolor_panel_background.9.png位于drawable文件夹中。这也可以在AndroidSDKres文件夹中找到。以下是主要Activity。packagecom.customdialog;importandroid.app.Activity;importandroid.app.AlertDialog;importandroid.app.Dialog;importand