new AlertDialog.Builder(this)
.setTitle("请做出你的选择")
.setIcon(R.mipmap.ic_launcher)
.setPositiveButton("确认",null)
.setNegativeButton("取消",null)
.setSingleChoiceItems(new String[]{"上海", "广东",
"北京", "浙江"}, 0, new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which)
{
}
})
.create().show();
AlertDialog dialog=new AlertDialog.Builder(this)
.setTitle("你的兴趣爱好有哪些")
.setIcon(R.mipmap.ic_launcher)
.setMultiChoiceItems(new String[]{"看书","运动","音
乐","烹饪"},null,null)
.setPositiveButton("确认",null)
.setNegativeButton("取消",null)
.create();
dialog.show();
ProgressDialog prg=new ProgressDialog(this);
prg.setTitle("进度显示");
prg.setIcon(R.mipmap.ic_launcher);
prg.setMessage("正在复制,请稍后");
prg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
prg.show();
Toast.makeText(this,"您做的是多项选择",Toast.LENGTH_LONG).show();
new AlertDialog.Builder(this)
.setTitle("提示")
.setIcon(R.mipmap.ic_launcher)
.setMessage("确认退出吗?")
.setPositiveButton("确认",null)
.setNegativeButton("取消",null)
.create().show();
AlertDialog dialog=new AlertDialog.Builder(this)
.setTitle("提示")
.setIcon(R.mipmap.ic_launcher)
.setMessage("确认退出吗?")
.setPositiveButton("确认",null)
.setNegativeButton("取消",null)
.create();
dialog.show();
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下列游戏,您比较喜欢:" />
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="您选择的是:" />
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="王者荣耀" />
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="和平精英" />
<CheckBox
android:id="@+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="英雄联盟" />
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"/>
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="默认的" />
</LinearLayout>