关于Activity一些问题
切换Activity所走的生命周期
众所周知
A->B
A :onPause()
B:onCreate()->onStart()->onResume()
A:onStop()
但是为什么走onPause(),后走onStop()呢
onPause() :
1、onPause() 中,切记 是 只有当启动另一个Activity时才会进入onPause状态,而不是被遮挡才会走onPause方法
2、同时呢Dialog和Toast得源码都是windowmanager.addView()方法来添加得, 他们都是一个个View,因此对于Activity得生命周期不会影响
ArrayList怎么变成线程安全 可以通过collections.synchronizedList() collections中对于这些方法都进行了加锁
以上都是在网上查看别人的资料所获得
报错Unable to add window android.view.ViewRootImpl$W@7e2686c – permission denied for window type 2010
是因为没有给权限
切记6.0以上还需要申请权限
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
// layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
layoutParams.type =WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
8.0以后不能使用上边的type,如果使用的话就会出上面的报错
当调用refreshLayout上拉加载下拉刷新的时候。
布局必须使用match_parent,或者固定多大,如果使用wrap_content的话。
上拉加载的时候,当你松手,加载布局会消失