shrink_to_middle.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:interpolator="@android:anim/linear_interpolator" android:fromXScale="1.0" android:toXScale="1.0" android:fromYScale="1.0" android:toYScale="0.0" android:fillAfter="false" android:duration="200" /> <translate android:fromYDelta="0" android:toYDelta="50%" android:duration="200"/> </set>grow_from_middle.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:interpolator="@android:anim/linear_interpolator" android:fromXScale="1.0" android:toXScale="1.0" android:fromYScale="0.0" android:toYScale="1.0" android:fillAfter="false" android:startOffset="200" android:duration="200" /> <translate android:fromYDelta="50%" android:toYDelta="0" android:startOffset="200" android:duration="200"/> </set>
通过右键删除一个listView item 需要知道索引号 然后从数组中删除
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
removeItemFromListById(info.id);
}
屏幕旋转 Activity 的生命周期变化:
1、Activity 不重启请在 AndroidManifest.xml 设置如下:
......
<activity android:name=".app.CustomDialogActivity"
android:label="@string/activity_custom_dialog"
android:configChanges="orientation|keyboardHidden"
>
......
2、如果不设置则启动如下:
第一次执行
onCreate(null)
onStart()
onPostCreate()
onResume()
onPostResume()
可将屏幕旋转以后:
onSaveInstanceState()
onPause()
onStop()
onDestroy()
onCreate(Bundle[{android:viewHierarchyState=Bundle[{android:views=android.util.SparseArray@43370a48}], key=123}])
onStart()
onRestoreInstanceState()
onPostCreate()
onResume()
onPostResume()
onDestroy() 证明杀掉了你的 activity, onCreate() 又重新启动了你的 activity
代码:
......
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_dialog_activity);
Log.w("Test", "onCreate(" + savedInstanceState + ")");
}
protected void onRestart() {
super.onRestart();
Log.w("Test", "onRestart()");
}
protected void onStart() {
super.onStart();
Log.w("Test", "onStart()");
}
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
Log.w("Test", "onRestoreInstanceState()");
}
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
Log.w("Test", "onPostCreate()");
}
protected void onResume() {
super.onResume();
Log.w("Test", "onResume()");
}
protected void onPostResume() {
super.onPostResume();
Log.w("Test", "onPostResume()");
}
protected void onSaveInstanceState(Bundle outState) {
outState.putInt("key", 123);
super.onSaveInstanceState(outState);
Log.w("Test", "onSaveInstanceState()");
}
protected void onPause() {
super.onPause();
Log.w("Test", "onPause()");
}
protected void onStop() {
super.onStop();
Log.w("Test", "onStop()");
}
protected void onDestroy() {
super.onDestroy();
Log.w("Test", "onDestroy()");
}
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.w("Test", "onNewIntent()");
}
.....