Android 常用代码---对话框
来源:互联网 发布:阮佳网络班 编辑:程序博客网 时间:2024/05/16 12:59
1
提示对话框
权限
代码
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Put your question here?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// put your code here
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// put your code here
dialog.cancel();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
2
进程对话框
权限
代码
ProgressDialog dialog = ProgressDialog.show(this, "Your Title", "Put your message here", true);
3
进程栏对话框
权限
代码
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMax(PROGRESS_MAX);
progressDialog.setMessage("Put your message here");
progressDialog.setCancelable(false);
progressDialog.incrementProgressBy(PROGRESS_INCREMENT);
4
日期选取器对话框
权限
代码
// Define the date picker dialog listener, which will be called after
// the user picks a date in the dialog displayed
DatePickerDialog.OnDateSetListener datePickerDialogListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
// put your code here
// update your model/view given with the date selected by the user
}
};
// Get the current date
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
// Create Date Picker Dialog
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
datePickerDialogListener,
year, month, day)
// Display Date Picker Dialog
datePickerDialog.show();
5
时间选取器对话框
权限
代码
// Define the date picker dialog listener, which will be called after
// the user picks a time in the dialog displayed
TimePickerDialog.OnTimeSetListener timePickerDialogListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// put your code here
// update your model/view given with the date selected by the user
}
};
// Get the current time
Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create Time Picker Dialog
TimePickerDialog timerPickerDialog = new TimePickerDialog(this,
timePickerDialogListener, hour, minute, false);
// Display Time Picker Dialog
timerPickerDialog.show();
6
自定义对话框
权限
代码
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.yourLayoutId);
dialog.show();
7
自定义提示对话框
权限
代码
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.yourLayoutId, (ViewGroup) findViewById(R.id.yourLayoutRoot));
AlertDialog.Builder builder = new AlertDialog.Builder(this);
.setView(layout);
AlertDialog alertDialog = builder.create();
alertDialog.show();
- Android 常用代码---对话框
- android 常用对话框 ---转载
- 常用的Android对话框
- 常用的android对话框
- Android 常用对话框
- Android中常用对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android提示对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 常用的android弹出对话框
- 使用 jQuery 属性选择器获取服务器控件 ClientID
- 中位数(又称中值,英语:Median)
- socket网络编程--简单的多人聊天
- 基于Android的SDIO-WIFI移植(1)(2)
- _beginthread,在控制台任意位置显示字符
- Android 常用代码---对话框
- lua的string.format为什么比".."慢
- 循环结构while和do_while
- ssh配置
- DWR的配置文件
- 获取oracle 表字段,表名,以及主键之类等等的信息(转)
- 函数和存储过程
- A + B Problem II
- dwr的知识详解和例子