下面列出了android.widget.LinearLayout#removeViewAt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Recycles items from specified layout.
* There are saved only items not included to specified range.
* All the cached items are removed from original layout.
*
* @param layout the layout containing items to be cached
* @param firstItem the number of first item in layout
* @param range the range of current wheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
/**
* Recycles items from specified layout.
* There are saved only items not included to specified range.
* All the cached items are removed from original layout.
*
* @param layout the layout containing items to be cached
* @param firstItem the number of first item in layout
* @param range the range of current spinnerwheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
/**
* Recycles items from specified layout.
* There are saved only items not included to specified range.
* All the cached items are removed from original layout.
*
* @param layout the layout containing items to be cached
* @param firstItem the number of first item in layout
* @param range the range of current wheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
/**
* Recycles items from specified layout.
* There are saved only items not included to specified range.
* All the cached items are removed from original layout.
*
* @param layout the layout containing items to be cached
* @param firstItem the number of first item in layout
* @param range the range of current wheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
/**
* Recycles items from specified layout.
* There are saved only items not included to specified range.
* All the cached items are removed from original layout.
*
* @param layout the layout containing items to be cached
* @param firstItem the number of first item in layout
* @param range the range of current wheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++;
}
index++;
}
return firstItem;
}
/**
* Recycles items from specified layout.
* There are saved only items not included to specified range.
* All the cached items are removed from original layout.
*
* @param layout the layout containing items to be cached
* @param firstItem the number of first item in layout
* @param range the range of current wheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
/**
* Recycles items from specified layout.
* There are saved only items not included to specified range.
* All the cached items are removed from original layout.
*
* @param layout the layout containing items to be cached
* @param firstItem the number of first item in layout
* @param range the range of current wheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range, int currentItem) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount(); ) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index, currentItem);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
public int recycleItems(LinearLayout linearlayout, int i, ItemsRange itemsrange)
{
int j = 0;
int k = i;
while (j < linearlayout.getChildCount())
{
if (!itemsrange.contains(i))
{
a(linearlayout.getChildAt(j), i);
linearlayout.removeViewAt(j);
if (j == 0)
{
k++;
}
} else
{
j++;
}
i++;
}
return k;
}
/**
* Recycles items from specified layout.
* There are saved only items not included to specified range.
* All the cached items are removed from original layout.
*
* @param layout the layout containing items to be cached
* @param firstItem the number of first item in layout
* @param range the range of current wheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
/**
* Recycles items from specified layout.
* There are saved only items not included to specified range.
* All the cached items are removed from original layout.
*
* @param layout the layout containing items to be cached
* @param firstItem the number of first item in layout
* @param range the range of current spinnerwheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
/**
* Recycles items from specified layout.
* There are saved only items not included to specified range.
* All the cached items are removed from original layout.
*
* @param layout the layout containing items to be cached
* @param firstItem the number of first item in layout
* @param range the range of current wheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
/**
* 把系统自身请求失败时的网页隐藏
*/
protected void hideErrorPage() {
LinearLayout webParentView = (LinearLayout) mWebView.getParent();
mIsErrorPage = false;
while (webParentView.getChildCount() > 1) {
webParentView.removeViewAt(0);
}
}
public void removeItem(int column, int index){
BoardItem item = (BoardItem)((ViewGroup)((ViewGroup)boardView.getChildAt(0)).getChildAt(0)).getChildAt(column);
ScrollView scrollView = (ScrollView)item.getChildAt(1);
LinearLayout llColumn = (LinearLayout)scrollView.getChildAt(0);
llColumn.removeViewAt(index);
llColumn.invalidate();
columns.get(column).objects.remove(index);
columns.get(column).views.remove(index);
}
/**
* Update a existing view with some column.
*
* @param position Current position of the cell.
* @param viewGroup Container of the cell.
* @param layout Layout saved of the cell.
*/
private void updateItemRow(int position, ViewGroup viewGroup, LinearLayout layout) {
// we remove view that aren't needed for the row
while(layout.getChildCount()>rows.get(position).size()){
layout.removeViewAt(layout.getChildCount()-1);
}
for (int i = 0; i < rows.get(position).size(); i++) {
int currentPos = rows.get(position).indexFirstItem + i;
View insideView = layout.getChildAt(i);
View theView = super.getView(currentPos, insideView, viewGroup);
// Set the width of this column
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
params.weight = rows.get(position).get(i).colSpan;
if (i != mNumColumns - 1)// last col
params.setMargins(0, 0, cellMargin, 0);
theView.setLayoutParams(params);
theView.setOnClickListener(new ListItemClickListener(currentPos));
if (!theView.equals(insideView)) {
if (layout.getChildCount() > i) {
layout.removeViewAt(i);
}
layout.addView(theView, i);
}
}
}
public void removeBreadcrumbItemFrom(int position) {
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.breadcrumb_scroll_view_inner_layout);
Log.d(TAG, "[toolbar] removeBreadcrumbItemFrom getChildCount():" + linearLayout.getChildCount() + " position:" + position);
for (int i = linearLayout.getChildCount(); i > position; i--) {
Log.d(TAG, "[toolbar] remove i:" + i + " ->" + (i - 1));
if (linearLayout.getChildAt(i - 1) != null) {
linearLayout.removeViewAt(i - 1);
}
}
}
private View recycleItemRow(View convertView, RowComputeResult rowInfo) {
int i;
LinearLayout ll = (LinearLayout) convertView;
for (i = 0; i < rowInfo.group.mDisplayCols; i++) {
View view = ll.getChildAt(i);
View newView = getItemView(rowInfo, i, view, ll);
if (view != newView) {
LinearLayout.LayoutParams thisViewParams = setupLayoutParams(newView);
ll.removeViewAt(i);
ll.addView(newView, i, thisViewParams);
}
}
return ll;
}
public void onClick(View v) {
LinearLayout layout = (LinearLayout)findViewById(R.id.inner_content);
int num = layout.getChildCount();
if (num > 0) {
layout.removeViewAt(num-1);
}
}
public void popBreadcrumbItem(int position) {
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.breadcrumb_scroll_view_inner_layout);
if (linearLayout.getChildAt(position) != null) {
linearLayout.removeViewAt(position);
}
}
protected void removeChild(LinearLayout layout, int position) {
layout.removeViewAt(position);
}