Java Code Examples for android.widget.GridView#INVALID_POSITION
The following examples show how to use
android.widget.GridView#INVALID_POSITION .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DragGridView.java From DragGridView with Apache License 2.0 | 6 votes |
/** * 触摸移动时,window更新 * * @param ev */ private void updateWindow(MotionEvent ev) { if (mode == MODE_DRAG) { float x = ev.getRawX() - mX; float y = ev.getRawY() - mY; if (layoutParams != null) { layoutParams.x = (int) x; layoutParams.y = (int) y; mWindowManager.updateViewLayout(dragView, layoutParams); } float mx = ev.getX(); float my = ev.getY(); int dropPosition = pointToPosition((int) mx, (int) my); Log.i(TAG, "dropPosition : " + dropPosition + " , tempPosition : " + tempPosition); if (dropPosition == tempPosition || dropPosition == GridView.INVALID_POSITION) { return; } itemMove(dropPosition); } }
Example 2
Source File: SignInFragment.java From android-topeka with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { if (savedInstanceState != null) { final int savedAvatarIndex = savedInstanceState.getInt(KEY_SELECTED_AVATAR_INDEX); if (savedAvatarIndex != GridView.INVALID_POSITION) { mSelectedAvatar = Avatar.values()[savedAvatarIndex]; } } super.onCreate(savedInstanceState); }
Example 3
Source File: DragGridView.java From DragGridView with Apache License 2.0 | 5 votes |
/** * 手指抬起时,item下落 */ private void itemDrop() { if (tempPosition == position || tempPosition == GridView.INVALID_POSITION) { getChildAt(position).setVisibility(VISIBLE); } else { ListAdapter adapter = getAdapter(); if (adapter != null && adapter instanceof DragGridAdapter) { ((DragGridAdapter) adapter).exchangePosition(position, tempPosition, false); } } }