Activity转化成View

时间:2014-08-26 03:10:15   收藏:0   阅读:201

1.LocaActivityManager am = new LocalActivityManager(Context,true);

2.Window window = am.startActivity("tag",new Intent());

3.View view = window.getDecorView();


接下来一定要在3个生命周期函数里调用如下方法,否则会抛出异常:java.lang.IllegalStateException: Activities can‘t be added until the containing group has been created.

onCreate()方法里调用am.dispatchCreate(savedInstanceState);


onPause()方法里调用am.dispatchPause(true);


onResume()方法里调用am.dispatchResume();

本文出自 “严富坤-编程技术” 博客,请务必保留此出处http://kinbos.blog.51cto.com/2092114/1544869

原文:http://kinbos.blog.51cto.com/2092114/1544869

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!