一.单选对话框

1.常规用法同一般对话框

2.Builder方法:设置单选选项setSingleChoiceItems(选项数组,默认被选中的选项索引,点击监听器DialogInterface.OnClickListener()):

onClick(DialogInterface dialog, int which):①which表示哪一个选项被选中②关闭对话框dialog.dismiss();

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:andro
 3     xmlns:tools="http://schemas.android.com/tools"
 4     android:layout_width="match_parent"
 5     android:layout_height="match_parent"
 6     android:paddingBottom="@dimen/activity_vertical_margin"
 7     android:paddingLeft="@dimen/activity_horizontal_margin"
 8     android:paddingRight="@dimen/activity_horizontal_margin"
 9     android:paddingTop="@dimen/activity_vertical_margin"
10     tools:context="com.hanqi.testapp2.TestActivity5"
11     android:orientation="vertical">
12  <Button
13         android:layout_width="match_parent"
14         android:layout_height="wrap_content"
15         android:text="单选对话框"
16         android:onClick="bt2_OnClick"/>
17 </LinearLayout>
单选对话框

相关文章:

  • 2021-08-12
  • 2022-02-24
  • 2022-12-23
  • 2022-01-30
  • 2021-12-19
  • 2022-12-23
  • 2021-11-01
猜你喜欢
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
  • 2022-12-23
相关资源
相似解决方案