Android的标准对话框最多可以有几个按钮?显示对话框按钮的方法是什么?
3个。

new AlertDialog.Builder(this).setTitle("我的对话框").setPositiveButton("关闭",    new DialogInterface.onClickListener(){        public void onClick(DialogInterface dialog, int whichButton){            //TODO        }    }).show();

如何在只使用AlertDialog,不使用外部布局的情况下实现一个列表?

使用AlertDialog.Builder.setItems()方法。

http://www.open-open.com/lib/view/open1326155119828.html


如何将字符串数组作为数据源以列表方式显示在标准对话框中,并在列表项后面加上选项按钮?
使用AlertBuilder.Builder.setSingleChoiceItems方法。


如何设置对话框进度条?
长型进度条对话框:

xh_pDialog = new ProgressDialog(Activity01.this);xh_pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);xh_pDialog.setTitle("提示");xh_pDialog.setMessage("这是一个长形进度条对话框");xh_pDialog.setIcon(R.drawable.img2);xh_pDialog.setIndeterminate(false);xh_pDialog.setProgress(100);xh_pDialog.setCancelable(true);xh_pDialog.show();

圆形:

xh_pDialog = new ProgressDialog(Activity01.this);xh_pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);xh_pDialog.setTitle("提示");xh_pDialog.setMessage("这是一个圆形进度条对话框");xh_pDialog.setIcon(R.drawable.img1);xh_pDialog.setIndeterminate(false);xh_pDialog.setCancelable(true);xh_pDialog.setButton("确定", new Bt1DialogListener());xh_pDialog.show();


如何在标准对话框中任意放置可视组件?

使用AlertDialog.Builder.setView方法。


显示对话框有几种方式?

1:直接使用AlertDialog显示对话框。

2:Activity.showDialog(int),该方法会调用Activity.onCreateDialog方法,并将int参数传入,然后根据参数值决定显示什么样的对话框。


如何改变对话框的显示位置?

Window window = alertDialog.getWindow();window.setGravity(Gravity.TOP | Gravity.LEFT)

如何改变对话框的透明度?

设置Window的alpha属性。


显示Toast的代码?

Toast.makeText(this, "我的信息", Toast.LENGTH_LONG)


下面的代码可以正常显示Toast信息框吗?为什么?

Toast toast = new Toast(this);toast.setText("xxx");toast.show();

不能。makeText方法会创建一个带TextView的View对象,而setText方法设置这个textView组件中的文本。


如何控制Toast信息框的显示和关闭?
Toast类中有一个内嵌类TN,该类中有两个方法show和hide,分别用来显示和关闭Toast信息框。需要用Java反射获取TN对象。


显示notification的步骤?

1:调用Context.getSystemService(NOTIFICATION_SERVICE)方法即可返回NotificationManager实例

2:用Notification构造函数 public Notification(int icon, CharSequence tickerText, long when)构造Notification实例 

3:notify()发出通知  cancel(...)取消通知


如何在单击notification后弹出一个activity?

使用PendingIntent.getActivity方法获取一个PendingIntent对象,并将其传入setLatestEventInfo方法的最后一个参数。


如何从状态栏清除notification?

使用NotificationManager.cancel方法。


如何将notification放在“正在进行”栏中?

设置notification的flag属性为ONGOING_EVENT。


如何自定义Notification?

设置Notification.contentView变量。


Android支持哪几种菜单?

选项菜单、上下文菜单、子菜单。


哪些菜单可以显示图像?

选项菜单(菜单项)、上下文菜单和子菜单(仅限菜单头)


创建子菜单的核心代码?

@Overridepublic boolean onCreateOptionsMenu(Menu menu) {    SubMenu uploadSubMenu=menu.addSubMenu(0, UPLOAD, 0, "上传");    uploadSubMenu.setIcon(R.drawable.upload);    uploadSubMenu.setHeaderIcon(R.drawable.upload);//设置子菜单的标题    uploadSubMenu.setHeaderTitle("上传参数设置");//设置子菜单的标题  默认为“上传”    uploadSubMenu.add(0, SUB_UPLOAD_A, 0, "上传参数1");    uploadSubMenu.add(0, SUB_UPLOAD_B, 0, "上传参数2");    SubMenu downloadSubMenu=menu.addSubMenu(0, DOWNLOAD, 0, "下载");    downloadSubMenu.setIcon(R.drawable.download);    return super.onCreateOptionsMenu(menu);}








更多相关文章

  1. switchpreference属性
  2. android - AsyncTask 的使用
  3. android怎样将textview置于imageview之上
  4. android屏幕自适应4方法案例整合
  5. Android(安卓)自定义 Dialog 大小 位置 样式
  6. Android的快速开发框架afinal
  7. android 学习(2)对话框
  8. Android动画效果
  9. Android(安卓)中文 API (93) —— BaseExpandableListAdapter

随机推荐

  1. android.graphics.Camera, 3D 的效果
  2. SQLite3主键自动递增
  3. Android(安卓)View状态保存
  4. android的processLifeCycle
  5. SystemUI密码解锁后指纹识别清除次数
  6. Android(安卓)Room 使用详解
  7. Android(安卓)爬坑路
  8. Android组件View绘制流程原理分析
  9. 利用drozer进行Andriod安全测试
  10. Android多媒体学习十三:检索MediaStore中