Android游戏开发系列教程第六讲(菜单对话框)

1.Menu(菜单)
a.OptionMenu(选项菜单)
核心方法:
onCreateOptionMenu//选项菜单创建前调用
onMenuOpened//菜单打开前调用
onOptionsItemSelected//选项菜单选中时调用
onOptionsMenuClosed//选项菜单关闭前调用
onPrepareOptionsMenu//选项菜单显示前调用
b.ContextMenu(上下文菜单)
核心方法:
onCreateContextMenu//创建菜单
onContextItemSelected//响应选中的事件
c.SubMenu(子菜单)
核心方法:
addSubMenu//添加子菜单
2.Dialog对话框
有三个子类:
ProgressDialog
DatePickerDialog
TimePickerDialog
a.AlertDialog(警告对话框)
三个按钮:
setPositiveButton
setNegativeButton
setNeutralButton
b.ProgressDialog
核心API:
final ProgressDialog progress = new ProgressDialog(this);
progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progress.setMax(100);
progress.setProgress(40);
progress.show();
new Thread(){
@Override
public void run() {
int p = 1;
while(true){
p++;
progress.setProgress(p);
if(p >= 100){
progress.dismiss();
}
try{
Thread.sleep(1000);
}catch(InterruptedException e){
e.printStackTrace();
}
}
}
}.start();
C.DatePickerDialog
核心API:
DatePickerDialog dialog = new DatePickerDialog(this,new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
System.out.println(year+"-"+monthOfYear+"-"+dayOfMonth);
}
},2011,12,18);
/**显示对话框*/
dialog.show();
错误:current should be >= start and <= end
d.TimePickerDialog
核心API:
TimePickerDialog dialog = new TimePickerDialog(this,new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
System.out.println(hourOfDay+"-"+minute);
}
/**20是小时,此时表示的19点03分,true是表示使用24小时制*/
},20,3,true);

dialog.show();

学习源码:http://download.csdn.net/detail/qq1059458376/4695775


你可能感兴趣的:(android)