本文整理了Java中android.widget.GridView.getNumColumns()
方法的一些代码示例,展示了GridView.getNumColumns()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.getNumColumns()
方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:getNumColumns
暂无
代码示例来源:origin: liaohuqiu/android-GridViewWithHeaderAndFooter
@TargetApi(11)
private int getNumColumnsCompatible() {
if (Build.VERSION.SDK_INT >= 11) {
return super.getNumColumns();
} else {
try {
Field numColumns = GridView.class.getDeclaredField("mNumColumns");
numColumns.setAccessible(true);
return numColumns.getInt(this);
} catch (Exception e) {
if (mNumColumns != -1) {
return mNumColumns;
}
throw new RuntimeException("Can not determine the mNumColumns for this API platform, please call setNumColumns to set it.");
}
}
}
代码示例来源:origin: square/assertj-android
@TargetApi(HONEYCOMB)
public GridViewAssert hasColumnCount(int count) {
isNotNull();
int actualCount = actual.getNumColumns();
assertThat(actualCount) //
.overridingErrorMessage("Expected column count <%s> but was <%s>.", count, actualCount) //
.isEqualTo(count);
return this;
}
代码示例来源:origin: MyLifeMyTravel/AndroidDemo
public int getNumColums() {
return mGvUploadImage.getNumColumns();
}
代码示例来源:origin: 1993hzw/Doodle
public int getColumnCount() {
return mGridView.getNumColumns();
}
代码示例来源:origin: stackoverflow.com
GridView mGridView = (GridView)findViewById(R.id.gridview);
int column_coutnt = mGridView.getNumColumns();
代码示例来源:origin: stackoverflow.com
GridView myGridView = (GridView) findViewById(R.id.my_grid_view);
AppConst.NUM_OF_COLUMNS = myGridView.getNumColumns();
代码示例来源:origin: OceanLabs/Android-Print-SDK
/*****************************************************
*
* Returns the number of product items.
*
*****************************************************/
@Override
public int getCount()
{
// We don't want to calculate the apparent item count in the constructor, because
// setting the number of columns for the GridView is requested after the layout has
// been inflated, and usually results in the adaptor being created before the change
// has taken effect.
int columnCount = mGridView.getNumColumns();
// We always round the number of images to be a multiple of the column count, so we can display a placeholder
// image in any 'missing' slots.
mApparentItemCount = ( columnCount > 1 ? ( ( mActualItemCount + ( columnCount / 2 ) ) / columnCount ) * columnCount: mActualItemCount );
return ( mApparentItemCount );
}
代码示例来源:origin: michelelacorte/AndroidAppShortcuts
/**
* Get grid size
* @param gridView AdapterView
* @return GridSize
*/
public static GridSize getGridSize(AdapterView gridView){
int nColumn = ((GridView) gridView).getNumColumns();
double nRow = Math.ceil((double)gridView.getCount()/(double)((GridView) gridView).getNumColumns());
Log.d(TAG, "Number of Row: " + (int)nRow + "\nNumber of Column: " + nColumn);
return new GridSize(nColumn, (int)nRow);
}
代码示例来源:origin: zzkong/BaseProject
@TargetApi(11)
private int getNumColumnsCompatible() {
if (Build.VERSION.SDK_INT >= 11) {
return super.getNumColumns();
} else {
try {
Field numColumns = GridView.class.getDeclaredField("mNumColumns");
numColumns.setAccessible(true);
return numColumns.getInt(this);
} catch (Exception e) {
if (mNumColumns != -1) {
return mNumColumns;
}
throw new RuntimeException("Can not determine the mNumColumns for this API platform, please call setNumColumns to set it.");
}
}
}
代码示例来源:origin: navyifanr/AndroidTrainingDemo
@TargetApi(11)
private int getNumColumnsCompatible() {
if (Build.VERSION.SDK_INT >= 11) {
return super.getNumColumns();
} else {
try {
Field numColumns = GridView.class.getDeclaredField("mNumColumns");
numColumns.setAccessible(true);
return numColumns.getInt(this);
} catch (Exception e) {
if (mNumColumns != -1) {
return mNumColumns;
}
throw new RuntimeException("Can not determine the mNumColumns for this API platform, please call setNumColumns to set it.");
}
}
}
代码示例来源:origin: madreain/AndroidDream
@TargetApi(11)
private int getNumColumnsCompatible() {
if (Build.VERSION.SDK_INT >= 11) {
return super.getNumColumns();
} else {
try {
Field numColumns = GridView.class.getDeclaredField("mNumColumns");
numColumns.setAccessible(true);
return numColumns.getInt(this);
} catch (Exception e) {
if (mNumColumns != -1) {
return mNumColumns;
}
throw new RuntimeException("Can not determine the mNumColumns for this API platform, please call setNumColumns to set it.");
}
}
}
代码示例来源:origin: com.squareup.assertj/assertj-android
@TargetApi(HONEYCOMB)
public GridViewAssert hasColumnCount(int count) {
isNotNull();
int actualCount = actual.getNumColumns();
assertThat(actualCount) //
.overridingErrorMessage("Expected column count <%s> but was <%s>.", count, actualCount) //
.isEqualTo(count);
return this;
}
代码示例来源:origin: michelelacorte/AndroidAppShortcuts
/**
* Get position in grid
* @param currentXPosition int
* @param currentYPosition int
* @param gridView AdapterView
* @return int
*/
private int getPositionInGrid(int currentXPosition, int currentYPosition, AdapterView gridView){
int positionInGrid = 0;
if(gridView != null) {
positionInGrid = ((GridView) gridView).pointToPosition(currentXPosition, currentYPosition);
positionInGrid -= ((GridView) gridView).getNumColumns();
positionInGrid %= ((GridView) gridView).getNumColumns();
Log.d(TAG, "Position In Grid: " + String.valueOf(positionInGrid));
if(positionInGrid < 0){
positionInGrid = ((GridView) gridView).pointToPosition(currentXPosition, currentYPosition);
Log.w(TAG, "Position In Grid lower than 0, trying again, positionInGrid: " + String.valueOf(positionInGrid));
}
}
return positionInGrid;
}
代码示例来源:origin: com.nhaarman.listviewanimations/lib-core
/**
* Returns the delay in milliseconds after which animation for View with position mLastAnimatedPosition + 1 should start.
*/
@SuppressLint("NewApi")
private int calculateAnimationDelay(final int position) {
int delay;
int lastVisiblePosition = mListViewWrapper.getLastVisiblePosition();
int firstVisiblePosition = mListViewWrapper.getFirstVisiblePosition();
int numberOfItemsOnScreen = lastVisiblePosition - firstVisiblePosition;
int numberOfAnimatedItems = position - 1 - mFirstAnimatedPosition;
if (numberOfItemsOnScreen + 1 < numberOfAnimatedItems) {
delay = mAnimationDelayMillis;
if (mListViewWrapper.getListView() instanceof GridView && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
int numColumns = ((GridView) mListViewWrapper.getListView()).getNumColumns();
delay += mAnimationDelayMillis * (position % numColumns);
}
} else {
int delaySinceStart = (position - mFirstAnimatedPosition) * mAnimationDelayMillis;
delay = Math.max(0, (int) (-SystemClock.uptimeMillis() + mAnimationStartMillis + mInitialDelayMillis + delaySinceStart));
}
return delay;
}
代码示例来源:origin: gateship-one/odyssey
mScrollSpeed = (int) (1000 / timeScrollPerRow) * gw.getNumColumns();
} else {
mScrollSpeed = (int) (1000 / timeScrollPerRow);
代码示例来源:origin: hezhubo/HPlayer
@SuppressLint("NewApi")
private long calculateAnimationDelay() {
long delay;
int lastVisiblePosition = getAbsListView().getLastVisiblePosition();
int firstVisiblePosition = getAbsListView().getFirstVisiblePosition();
int numberOfItemsOnScreen = lastVisiblePosition - firstVisiblePosition;
int numberOfAnimatedItems = mLastAnimatedPosition - mFirstAnimatedPosition;
if (numberOfItemsOnScreen + 1 < numberOfAnimatedItems) {
delay = getAnimationDelayMillis();
if (getAbsListView() instanceof GridView && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
delay += getAnimationDelayMillis() * ((mLastAnimatedPosition + 1) % ((GridView) getAbsListView()).getNumColumns());
}
} else {
long delaySinceStart = (mLastAnimatedPosition - mFirstAnimatedPosition + 1) * getAnimationDelayMillis();
delay = mAnimationStartMillis + getInitialDelayMillis() + delaySinceStart - System.currentTimeMillis();
}
return Math.max(0, delay);
}
代码示例来源:origin: MoMoWait/LeanbackLauncher
return true;
}else if(keyCode == KeyEvent.KEYCODE_DPAD_UP){
int numCols = mAllAppGridView.getNumColumns();
int selectedPosition = mAllAppGridView.getSelectedItemPosition();
if(selectedPosition / numCols == 0)
代码示例来源:origin: michelelacorte/AndroidAppShortcuts
int mIconWidth = maxXScreen / ((GridView) gridView).getNumColumns();
int dim = (positionInGrid) * mIconWidth;
int layoutHeightTotal = DIM_HEIGHT * shortcuts.size() + 20;
代码示例来源:origin: michelelacorte/AndroidAppShortcuts
int mIconWidth = maxXScreen / ((GridView) gridView).getNumColumns();
int dim = (positionInGrid) * mIconWidth;
int layoutHeightTotal = DIM_HEIGHT * shortcuts.length + 20;
内容来源于网络,如有侵权,请联系作者删除!