View not attached to WindowManager 错误
来源:互联网 发布:window多线程编程 编辑:程序博客网 时间:2024/06/03 18:07
今天在学习2D绘图的时候,为了省事,在Activity的OnCreate里写下了如下代码
WindowManager wm;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
wm = (WindowManager) getSystemService(Service.WINDOW_SERVICE);
DemoButton button = new DemoButton(this);
setContentView(button);
WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.width = LayoutParams.WRAP_CONTENT;
params.height = LayoutParams.WRAP_CONTENT;
params.x = 50;
params.y = 50;
wm.updateViewLayout(button, params);
}
然后运行,报错,View not attached to WindowManager,自己对android的这些方面的理解这样看来真的很不到位,button并未如自己所想是attach到Window上的,WindowManager管理的是一组窗口,比如activity,dialog,以及通过addview添加到Window的悬浮窗(前提是这个view在添加之前没有任何parent,否则会出现异常,being add,but it already has a parent),更加深刻详细的解释在这里
http://blog.csdn.net/luoshengyang/article/details/8498908
暂时对WindowManager的理解就到这了,小弟才疏学浅,说的不对的地方请大家一定帮我指出来
- View not attached to WindowManager 错误
- Android中View not attached to window manager错误,android.view.WindowLeaked的解决方案
- view not attached to window manager
- View not attached to window manager
- illegalargumentexception: view not attached to window manager
- View not attached to window manager
- View not attached to window manager解决方案
- View not attached to window manager
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- View not attached to window manager
- android View not attached to window manager
- View not attached to window manager
- View not attached to window manager
- 动态规划、贪心、dynamic programming(DP)
- 碎碎念,一不小心就忘记了
- WAVE数据转成WAVE文件并输出语音
- keychain使用介绍
- ajax 提交form表单遇到的问题----1
- View not attached to WindowManager 错误
- centos限定端口访问
- PPPoE拨号技术(实验)
- STP高级特性(实验)
- Yii 引入js css jquery
- VTP配置及工作原理(实验)
- Ubuntu 快捷键
- arm中断(小结10)
- C++信号量 Semaphore 和 MFC中的 CSemaphore类使用