下面列出了android.widget.FrameLayout#removeViewAt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
FrameLayout view = (FrameLayout) object;
for (int i = 0; i < view.getChildCount(); i++) {
View childView = view.getChildAt(i);
if (childView instanceof PhotoView) {
childView.setOnClickListener(null);
childView.setOnLongClickListener(null);
GlideApp.with(container).clear(childView);
view.removeViewAt(i);
Logger.t(TAG).d("clean photoView");
}
}
container.removeView(view);
Logger.t(TAG).d("destroyItem");
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
FrameLayout view = (FrameLayout) object;
for (int i = 0; i < view.getChildCount(); i++) {
View childView = view.getChildAt(i);
if (childView instanceof PhotoView) {
childView.setOnClickListener(null);
childView.setOnLongClickListener(null);
GlideApp.with(container).clear(childView);
view.removeViewAt(i);
Logger.t(TAG).d("clean photoView");
}
}
container.removeView(view);
Logger.t(TAG).d("destroyItem");
}
/**
* Sets a view to be displayed when the list is empty with optional LayoutParams.
* @param view Displayed when the list is empty.
* @param params Information about how view's layout in the countainer.
*/
public void setEmptyView(View view, FrameLayout.LayoutParams params){
emptyView = view;
isEmptyViewEmptyText = true;
FrameLayout frameLayout = (FrameLayout) getView();
if (frameLayout == null)
return;
//In order to avoid having more than one emptyViews added to the layout
if (frameLayout.getChildCount() > 2)
frameLayout.removeViewAt(2);
if (this.emptyText != null)
frameLayout.findViewById(android.R.id.text1).setVisibility(View.GONE);
if (params == null) {
params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER;
}
frameLayout.addView(view, 1, params);
this.emptyViewAddedToLayout = true;
actuallySetEmptyView();
}
private void showErrorPage() {
FrameLayout webParentView = (FrameLayout) mWebView.getParent();
initErrorPage();//初始化自定义页面
while (webParentView.getChildCount() > 1) {
webParentView.removeViewAt(0);
}
@SuppressWarnings("deprecation")
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT);
webParentView.addView(mErrorView, 0, lp);
mIsErrorPage = true;
}