热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Androidgraphics:Howanalertwindowisdisplayed?

Androidgraphics:Howanalertwindowisdisplayed?一、initilizationanddatastructure.AlertDialoginh

Android graphics: How an alert window is displayed?

 

一、initilization and data structure.

AlertDialog inherites from Dialog and it hold a member of AlertController mAlert.

 

 

In dialog.java, Dialog in constrcuted. it creates a new phoneWindow, and store it in it's mWindow member.

 the window is registered in WMS. so it can interact with WMS to handle the input from users.

 

 

frameworks/base/policy/src/com/android/internal/policy/impl/Policy.java
frameworks/base/core/java/android/view/Window.java

 

 

164 Window w = PolicyManager.makeNewWindow(mContext);

mWindow = w;
w.setWindowManager(mWindowManager, null, null);
in AlertDiaog constructor, Dialog's phoneWindow will be passed to AlertController's mWindow
alertDialog.java
AlertDialog(Context context, int theme, boolean createThemeContextWrapper) {
mAlert = new AlertController(getContext(), this, getWindow());
}

 

 

二、show() function.

how the dialog window is shown??

you need to invoke the dialog.show() to display the dialog window, before this, you need to 

setup the contents of dialog.

the code snippet is like:

1 AlertDialog.Builder ad = new AlertDialog.Builder(cxt);
2
3 ad.setTitle(title);
4 ad.setMessage(message);
5
6 ad.setPositiveButton(
7 b1string,
8 new DialogInterface.OnClickListener() {
9
10 @Override
11 public void onClick(DialogInterface arg0, int arg1) {
12 // TODO Auto-generated method stub
13
14 }
15 }
16 );
17
18 ad.show();

 

I add a function to print the call stack :

E/SS ( 1973): com.android.internal.policy.impl.PhoneWindow$DecorView.setWindowBackground(PhoneWindow.java:2348)

 

E/SS ( 1973): com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2843)
E/SS ( 1973): com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2884)
E/SS ( 1973): com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
E/SS ( 1973): com.android.internal.app.AlertController.installContent(AlertController.java:262)
E/SS ( 1973): android.app.AlertDialog.onCreate(AlertDialog.java:337)
E/SS ( 1973): android.app.Dialog.dispatchOnCreate(Dialog.java:355)
E/SS ( 1973): android.app.Dialog.show(Dialog.java:260)

 

in the show() , 
1) it first invokes the AlertDialog.onCreate function to installDecor(), which generates the new decorview(), and inflate the view with the contents
2)
the decorView which acts as the root of the view, is registered to the Window manager.

public void show() {

             mWindowManager.addView(mDecor, l);

}
addview里面会生成新的viewroot
frameworks/base/core/java/android/view/WindowManagerGlobal.java

public void addView(View view, ViewGroup.LayoutParams params,

            Display display, Window parentWindow) {

         root = new ViewRootImpl(view.getContext(), display);

}

the role of viewroot is to interact with WMS, so it can receives key input from users, also it can request WMS to do something.

a Viewroot has a new layer, surface , phone window here. After this, it can invoke performTraversal() to ask Choreographer to draw the image.


转:https://www.cnblogs.com/geeks/p/3266051.html



推荐阅读
  • 如何在HTML中获取鼠标的当前位置
    本文介绍了在HTML中获取鼠标当前位置的三种方法,分别是相对于屏幕的位置、相对于窗口的位置以及考虑了页面滚动因素的位置。通过这些方法可以准确获取鼠标的坐标信息。 ... [详细]
  • GetWindowLong函数
    今天在看一个代码里头写了GetWindowLong(hwnd,0),我当时就有点费解,靠,上网搜索函数原型说明,死活找不到第 ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • Go GUIlxn/walk 学习3.菜单栏和工具栏的具体实现
    本文介绍了使用Go语言的GUI库lxn/walk实现菜单栏和工具栏的具体方法,包括消息窗口的产生、文件放置动作响应和提示框的应用。部分代码来自上一篇博客和lxn/walk官方示例。文章提供了学习GUI开发的实际案例和代码示例。 ... [详细]
  • 本文详细介绍了如何使用MySQL来显示SQL语句的执行时间,并通过MySQL Query Profiler获取CPU和内存使用量以及系统锁和表锁的时间。同时介绍了效能分析的三种方法:瓶颈分析、工作负载分析和基于比率的分析。 ... [详细]
  • Ihavethefollowingonhtml我在html上有以下内容<html><head><scriptsrc..3003_Tes ... [详细]
  • JDK源码学习之HashTable(附带面试题)的学习笔记
    本文介绍了JDK源码学习之HashTable(附带面试题)的学习笔记,包括HashTable的定义、数据类型、与HashMap的关系和区别。文章提供了干货,并附带了其他相关主题的学习笔记。 ... [详细]
  • Android工程师面试准备及设计模式使用场景
    本文介绍了Android工程师面试准备的经验,包括面试流程和重点准备内容。同时,还介绍了建造者模式的使用场景,以及在Android开发中的具体应用。 ... [详细]
  • 本文介绍了在MFC下利用C++和MFC的特性动态创建窗口的方法,包括继承现有的MFC类并加以改造、插入工具栏和状态栏对象的声明等。同时还提到了窗口销毁的处理方法。本文详细介绍了实现方法并给出了相关注意事项。 ... [详细]
  • JavaScript和HTML之间的交互是经由过程事宜完成的。事宜:文档或浏览器窗口中发作的一些特定的交互霎时。能够运用侦听器(或处置惩罚递次来预订事宜),以便事宜发作时实行相应的 ... [详细]
  • 本文详细介绍了Android中的坐标系以及与View相关的方法。首先介绍了Android坐标系和视图坐标系的概念,并通过图示进行了解释。接着提到了View的大小可以超过手机屏幕,并且只有在手机屏幕内才能看到。最后,作者表示将在后续文章中继续探讨与View相关的内容。 ... [详细]
  • 带添加按钮的GridView,item的删除事件
    先上图片效果;gridView无数据时显示添加按钮,有数据时,第一格显示添加按钮,后面显示数据:布局文件:addr_manage.xml<?xmlve ... [详细]
  • 本文总结了在编写JS代码时,不同浏览器间的兼容性差异,并提供了相应的解决方法。其中包括阻止默认事件的代码示例和猎取兄弟节点的函数。这些方法可以帮助开发者在不同浏览器上实现一致的功能。 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
author-avatar
神秘的绝代双角
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有