本文整理了Java中android.widget.GridView.getFirstVisiblePosition()
方法的一些代码示例,展示了GridView.getFirstVisiblePosition()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.getFirstVisiblePosition()
方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:getFirstVisiblePosition
暂无
代码示例来源:origin: stackoverflow.com
static int index;
private GridView gridView;
@Override
public void onResume(){
gridView.setSelection(index);
super.onResume();
}
@Override
public void onPause(){
index = gridView.getFirstVisiblePosition();
super.onPause();
}
代码示例来源:origin: stackoverflow.com
private int _savedGridPosition = 0;
private GridView _gridView;
...
@Override
protected void onSaveInstanceState (Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("grid_position", _gridView.getFirstVisiblePosition());
}
@Override
protected void onRestoreInstanceState (Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
if(savedInstanceState != null && savedInstanceState.containsKey("grid_position")) {
_savedGridPosition = savedInstanceState.getInt("grid_position");
}
}
@Override
protected void onResume() {
_gridView.smoothScrollToPosition(_savedGridPosition);
}
@Override void onPause() {
// set in onPause() too since onRestoreInstanceState() is only
// called when the Activity is destroyed and recreated.
_savedGridPosition = _gridView.getFirstVisiblePosition();
}
代码示例来源: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
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: fire3/sailorcast
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
boolean enable = false;
if (mGrid != null && mGrid.getChildCount() > 0) {
// check if the first item of the list is visible
boolean firstItemVisible = mGrid.getFirstVisiblePosition() == 0;
// check if the top of the first item is visible
boolean topOfFirstItemVisible = mGrid.getChildAt(0).getTop() == 0;
// enabling or disabling the refresh layout
enable = firstItemVisible && topOfFirstItemVisible;
}
mSwipeContainer.setEnabled(enable);
}
});
代码示例来源:origin: fire3/sailorcast
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
boolean enable = false;
if (mGrid != null && mGrid.getChildCount() > 0) {
// check if the first item of the list is visible
boolean firstItemVisible = mGrid.getFirstVisiblePosition() == 0;
// check if the top of the first item is visible
boolean topOfFirstItemVisible = mGrid.getChildAt(0).getTop() == 0;
// enabling or disabling the refresh layout
enable = firstItemVisible && topOfFirstItemVisible;
}
mSwipeContainer.setEnabled(enable);
}
});
代码示例来源: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: googlecreativelab/lipswap
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
boolean checked) {
//highlight stuff if it should be checked
GridViewItem item = (GridViewItem) mGridView
.getChildAt(position - mGridView.getFirstVisiblePosition());
item.animateHighlight(checked);
Log.d(TAG, "onItemCheckedStateChanged() " + position + " id: " + id + " checked: "
+ checked);
if (checked) {
mSelectedItems.add(item);
} else {
mSelectedItems.remove(item);
}
if (mSelectedItems.size() > 1) {
//more than one selected, so disable sharing
mode.getMenu().findItem(R.id.action_share).setEnabled(false);
} else if (mSelectedItems.size() == 1) {
mode.getMenu().findItem(R.id.action_share).setEnabled(true);
}
}
代码示例来源:origin: stackoverflow.com
public void getAllValues() {
View parentView = null;
int temp = 0;
int getTotal = 0;
int totQuan = 0;
int quan = 0;
for (int i = 0; i < list.getCount(); i++) {
parentView = getViewByPosition(i, list);
String getString = ((TextView) parentView
.findViewById(R.id.totalPrice)).getText().toString();
getTotal = Integer.parseInt(getString);
temp = temp + getTotal;
totQuan = Integer.parseInt(((TextView) parentView
.findViewById(R.id.counter)).getText().toString());
quan = quan + totQuan;
}
setTotalAmount(String.valueOf(temp), String.valueOf(quan));
}
public View getViewByPosition(int pos, GridView listView) {
final int firstListItemPosition = listView.getFirstVisiblePosition();
final int lastListItemPosition = firstListItemPosition
+ listView.getChildCount() - 1;
if (pos < firstListItemPosition || pos > lastListItemPosition) {
return listView.getAdapter().getView(pos, null, listView);
} else {
final int childIndex = pos - firstListItemPosition;
return listView.getChildAt(childIndex);
}
}
代码示例来源:origin: HenriDellal/emerald
final int nCategories = editableCategories.size();
ArrayList<String> editableCategoriesNames = new ArrayList<String>(nCategories);
final int position = grid.getFirstVisiblePosition();
for (String category: editableCategories) {
editableCategoriesNames.add(categories.getCategory(category).getRepresentName(this));
代码示例来源:origin: stackoverflow.com
(view.getFirstVisiblePosition() > 0
|| view.getChildAt(0).getTop() < view.getPaddingTop());
代码示例来源:origin: stackoverflow.com
Runnable mScroller = new Runnable() {
public void run() {
int firstPos = mGrid.getFirstVisiblePosition();
switch(mDirection) {
case DIR_UP: {
mLastSeenPosition = AdapterView.INVALID_POSITION;
if(position < mGrid.getFirstVisiblePosition()) {
mDirection = DIR_UP;
} else if (position > mGrid.getLastVisiblePosition()) {
代码示例来源:origin: chengzichen/KrGallery
return;
int position = listView.getFirstVisiblePosition();
WindowManager manager = (WindowManager) Gallery.applicationContext
.getSystemService(Activity.WINDOW_SERVICE);
内容来源于网络,如有侵权,请联系作者删除!