Fragment中获取Activity的Context (转)


    Fragment中获取Activity的Context时只需要this.getActivity()即可.
    而不是许多人说的this.getActivity().getApplicationContext(),如果用后者传入AlterDialog肯定会报错(android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application).
   因为只有activity才可以再开新的窗口.

转自:http://blog.chinaunix.net/uid-20544507-id-4262564.html

文章来自:http://www.cnblogs.com/wu-yun-jiang/p/4490895.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3