ViewPager裏的ViewGroup.removeView(View view);與ViewGroup.removeViewAt有什麼區別,爲什麼在自定義的PagerAdapter裏destroyItem方法中,用前者沒有錯誤,用後者,則會出現the specified child already
have a parent .you must call removeView on the child‘parent first。#Android# #ViewPager#
API:
-
public void removeViewAt(int index)
Removes the view at the specified position in the group.Note: do not invoke this method from
View.draw(android.graphics.Canvas)
,View.onDraw(android.graphics.Canvas)
,dispatchDraw(android.graphics.Canvas)
or any related method.- Parameters:
index
- the position in the group of the view to remove
-
public void removeView(View view)
Note: do not invoke this method from
View.draw(android.graphics.Canvas)
,View.onDraw(android.graphics.Canvas)
,dispatchDraw(android.graphics.Canvas)
or any related method.- Specified by:
removeView
in interfaceViewManager
- ViewManager:
-
Interface to let you add and remove child views to an Activity. To get an instance of this class, call
Context.getSystemService()
.
-
-
-
- 所以removeView只是將view從activity裏移除,而removeViewAt則是將view從ViewGroup裏移除?
- ----------------------------------------------------------------------求交流--------------------------------------------------------------------------------------------