标签:
Fragment中的代码 context 是null
public class PlaceholderFragment extends Fragment{ Context context = getActivity(); }
Activity中的代码 context不是null
public class MainActivity extends FragmentActivity { Context context = this; }
以下这样的方式获取context 会抛异常
public class MainActivity extends FragmentActivity { Context context = getApplicationContext();; }
标签:
原文地址:http://www.cnblogs.com/gcczhongduan/p/5378664.html