android.widget.GridView.getLastVisiblePosition()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中android.widget.GridView.getLastVisiblePosition()方法的一些代码示例,展示了GridView.getLastVisiblePosition()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.getLastVisiblePosition()方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:getLastVisiblePosition

GridView.getLastVisiblePosition介绍

暂无

代码示例

代码示例来源:origin: LiuGuiLinAndroid/LoveWallpaper

@Override
public void onScrollStateChanged(AbsListView absListView, int i) {
  if (i == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
    if (mGridView.getLastVisiblePosition() == mGridView.getCount() - 1) {
      ll_load_more.setVisibility(View.VISIBLE);
      loadData();
    }
  }
}

代码示例来源:origin: LiuGuiLinAndroid/LoveWallpaper

@Override
public void onScrollStateChanged(AbsListView absListView, int i) {
  if (i == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
    if (mGridView.getLastVisiblePosition() == mGridView.getCount() - 1) {
      ll_load_more.setVisibility(View.VISIBLE);
      loadData();
    }
  }
}

代码示例来源:origin: stackoverflow.com

@ViewById(R.id.gridViewId)
GridView gridView;

@ItemClick(R.id.gridViewId)
void itemClicked(int position) {
  int firstPosition = gridView.getFirstVisiblePosition();
  int lastPosition = gridView.getLastVisiblePosition();

  View clickedView;

  if ((position < firstPosition) || (position > lastPosition))
    clickedView = null;

  clickedView = gridView.getChildAt(position - firstPosition);
  // do sg with clicked view
}

代码示例来源:origin: stackoverflow.com

public class MainActivity extends Activity implements OnScrollListener {
   ArrayAdapter<String> adapter;
   GridView gridphoto;
   Button loadMore;
   @Override
   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);
     gridphoto = (GridView) findViewById(R.id.gridphoto);
     loadMore = (Button) findViewById(R.id.loadmore);
     gridphoto.setOnScrollListener(this);
     adapter= new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
     for (int i = 0; i < 80; i++) {
       adapter.add("dummy data " + i);
     }
     gridphoto.setAdapter(adapter);
   }
   @Override
   public void onScroll(AbsListView view, int firstVisibleItem,
       int visibleItemCount, int totalItemCount) {
     if (gridphoto.getLastVisiblePosition() + 1 == 80) {
       loadMore.setVisibility(View.VISIBLE); // Load More Button
     }
   }
   @Override
   public void onScrollStateChanged(AbsListView view, int scrollState) {
     // TODO Auto-generated method stub
   }
 }

代码示例来源:origin: stackoverflow.com

private View getViewByPosition(GridView gridView, int position) {
  int firstPosition = gridView.getFirstVisiblePosition();
  int lastPosition = gridView.getLastVisiblePosition();

  if ((position < firstPosition) || (position > lastPosition))
    return null;

  return gridView.getChildAt(position - firstPosition);
}

代码示例来源:origin: reloZid/android-anuto

private void updateArrowVisibility() {
    if (grid_maps.getChildCount() <= 0) {
      arrow_up.setVisibility(View.INVISIBLE);
      arrow_down.setVisibility(View.INVISIBLE);
      return;
    }

    if (grid_maps.getFirstVisiblePosition() == 0) {
      arrow_up.setVisibility(grid_maps.getChildAt(0).getTop() < -10 ? View.VISIBLE : View.INVISIBLE);
    } else {
      arrow_up.setVisibility(grid_maps.getFirstVisiblePosition() > 0 ? View.VISIBLE : View.INVISIBLE);
    }

    if (grid_maps.getLastVisiblePosition() == mAdapter.getCount() - 1) {
      arrow_down.setVisibility(grid_maps.getChildAt(grid_maps.getChildCount() - 1).getBottom() > grid_maps.getHeight() + 10 ? View.VISIBLE : View.INVISIBLE);
    } else {
      arrow_down.setVisibility(grid_maps.getLastVisiblePosition() < mAdapter.getCount() - 1 ? View.VISIBLE : View.INVISIBLE);
    }
  }
}

代码示例来源:origin: stackoverflow.com

} else if (position > mGrid.getLastVisiblePosition()) {
  mDirection = DIR_DOWN;
} else {

相关文章

GridView类方法