当前位置: 首页>>代码示例>>Java>>正文


Java AdapterView.INVALID_POSITION属性代码示例

本文整理汇总了Java中android.widget.AdapterView.INVALID_POSITION属性的典型用法代码示例。如果您正苦于以下问题:Java AdapterView.INVALID_POSITION属性的具体用法?Java AdapterView.INVALID_POSITION怎么用?Java AdapterView.INVALID_POSITION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.widget.AdapterView的用法示例。


在下文中一共展示了AdapterView.INVALID_POSITION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // Shortcuts that work no matter what is selected
    if (QMail.useVolumeKeysForListNavigationEnabled() &&
            (keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
            keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {

        final ListView listView = getListView();

        int currentPosition = listView.getSelectedItemPosition();
        if (currentPosition == AdapterView.INVALID_POSITION || listView.isInTouchMode()) {
            currentPosition = listView.getFirstVisiblePosition();
        }

        if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && currentPosition > 0) {
            listView.setSelection(currentPosition - 1);
        } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN &&
                currentPosition < listView.getCount()) {
            listView.setSelection(currentPosition + 1);
        }

        return true;
    }

    return super.onKeyDown(keyCode, event);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:26,代码来源:K9ListActivity.java

示例2: getViewAt

@Override
public RemoteViews getViewAt(int position) {
    if (position == AdapterView.INVALID_POSITION ||
            data == null || !data.moveToPosition(position)) {
        return null;
    }

    RemoteViews views = new RemoteViews(mContext.getPackageName(),
            R.layout.widget_detail_list_item);


    int articleTitleIndex = data.getColumnIndex(ArticleContract.ArticleEntry.COLUMN_ARTICLE_TITLE);
    String articleTitle = data.getString(articleTitleIndex);
    views.setTextViewText(R.id.news_widget_title, articleTitle);

    return views;
}
 
开发者ID:ansh94,项目名称:DailyTech,代码行数:17,代码来源:ArticleWidgetRemoteViewsFactory.java

示例3: onSaveInstanceState

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putString(Constants.ANIME_PATH, mPath);
    if (!mPrevPath.empty()) {
        ArrayList<String> copy = new ArrayList<String>(mPrevPath);
        outState.putStringArrayList(Constants.ANIME_PREV_PATH_LIST, copy);
    }
    if (mAdapter != null)
        mAdapter.onSaveInstanceState(outState);

    if (mActivatedPosition != AdapterView.INVALID_POSITION) {
        //Serialize and persist the activated item position.
        outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
        Log.d(TAG, STATE_ACTIVATED_POSITION + "=" + mActivatedPosition);
    }
    super.onSaveInstanceState(outState);
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:17,代码来源:LibraryFragment.java

示例4: onSaveInstanceState

@Override
public void onSaveInstanceState(Bundle outState) {
    if (mActivatedPosition != AdapterView.INVALID_POSITION) {
        //Serialize and persist the activated item position.
        outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
    }
    super.onSaveInstanceState(outState);
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:8,代码来源:AnimeCardGridFragment.java

示例5: adapterToListViewPosition

private int adapterToListViewPosition(int position) {
    if (position >= 0 && position < adapter.getCount()) {
        return position;
    }

    return AdapterView.INVALID_POSITION;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:7,代码来源:MessageListFragment.java

示例6: onSaveInstanceState

@Override
public void onSaveInstanceState(Bundle outState) {
	super.onSaveInstanceState(outState);
	if (activatedPosition != AdapterView.INVALID_POSITION) {
		// Serialize and persist the activated item position.
		outState.putInt(STATE_ACTIVATED_POSITION, activatedPosition);
	}
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:8,代码来源:ItemListAbstractFragment.java

示例7: onMoveUp

public void onMoveUp() {
    int currentPosition = listView.getSelectedItemPosition();
    if (currentPosition == AdapterView.INVALID_POSITION || listView.isInTouchMode()) {
        currentPosition = listView.getFirstVisiblePosition();
    }
    if (currentPosition > 0) {
        listView.setSelection(currentPosition - 1);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:9,代码来源:MessageListFragment.java

示例8: performAdapterViewItemClick

private void performAdapterViewItemClick() {
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(BGASwipeItemLayout.this);
        if (p != AdapterView.INVALID_POSITION) {
            view.performItemClick(view.getChildAt(p - view.getFirstVisiblePosition()), p, view.getAdapter().getItemId(p));
        }
    }
}
 
开发者ID:NEYouFan,项目名称:ht-recyclerviewadapter,代码行数:10,代码来源:BGASwipeItemLayout.java

示例9: getPositionForUniqueId

private int getPositionForUniqueId(long uniqueId) {
    for (int position = 0, end = adapter.getCount(); position < end; position++) {
        Cursor cursor = (Cursor) adapter.getItem(position);
        if (cursor.getLong(uniqueIdColumn) == uniqueId) {
            return position;
        }
    }

    return AdapterView.INVALID_POSITION;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:10,代码来源:MessageListFragment.java

示例10: getMessageAtPosition

private MessageReference getMessageAtPosition(int adapterPosition) {
    if (adapterPosition == AdapterView.INVALID_POSITION) {
        return null;
    }

    Cursor cursor = (Cursor) adapter.getItem(adapterPosition);

    String accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN);
    String folderName = cursor.getString(FOLDER_NAME_COLUMN);
    String messageUid = cursor.getString(UID_COLUMN);

    return new MessageReference(accountUuid, folderName, messageUid, null);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:13,代码来源:MessageListFragment.java

示例11: performAdapterViewItemClick

private void performAdapterViewItemClick() {
    if (getOpenStatus() != Status.Close) return;
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeLayout.this);
        if (p != AdapterView.INVALID_POSITION) {
            view.performItemClick(view.getChildAt(p - view.getFirstVisiblePosition()), p, view
                    .getAdapter().getItemId(p));
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SwipeLayout.java

示例12: performAdapterViewItemClick

private void performAdapterViewItemClick() {
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeItemLayout.this);
        if (p != AdapterView.INVALID_POSITION) {
            view.performItemClick(view.getChildAt(p - view.getFirstVisiblePosition()), p, view.getAdapter().getItemId(p));
        }
    }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:10,代码来源:SwipeItemLayout.java

示例13: performAdapterViewItemLongClick

private boolean performAdapterViewItemLongClick() {
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeItemLayout.this);
        if (p == AdapterView.INVALID_POSITION) return false;
        long vId = view.getItemIdAtPosition(p);
        boolean handled = false;
        try {
            Method m = AbsListView.class.getDeclaredMethod("performLongPress", View.class, int.class, long.class);
            m.setAccessible(true);
            handled = (boolean) m.invoke(view, SwipeItemLayout.this, p, vId);

        } catch (Exception e) {
            e.printStackTrace();

            if (view.getOnItemLongClickListener() != null) {
                handled = view.getOnItemLongClickListener().onItemLongClick(view, SwipeItemLayout.this, p, vId);
            }
            if (handled) {
                view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
        return handled;
    }
    return false;
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:27,代码来源:SwipeItemLayout.java

示例14: viewIdHitPosition

public int viewIdHitPosition(MotionEvent ev, int id) {
    final int x = (int) ev.getX();
    final int y = (int) ev.getY();

    int touchPos = mDslv.pointToPosition(x, y); // includes headers/footers

    final int numHeaders = mDslv.getHeaderViewsCount();
    final int numFooters = mDslv.getFooterViewsCount();
    final int count = mDslv.getCount();

    // Log.d("mobeta", "touch down on position " + itemnum);
    // We're only interested if the touch was on an
    // item that's not a header or footer.
    if (touchPos != AdapterView.INVALID_POSITION && touchPos >= numHeaders
            && touchPos < (count - numFooters)) {
        final View item = mDslv.getChildAt(touchPos - mDslv.getFirstVisiblePosition());
        final int rawX = (int) ev.getRawX();
        final int rawY = (int) ev.getRawY();

        View dragBox = id == 0 ? item : (View) item.findViewById(id);
        if (dragBox != null) {
            dragBox.getLocationOnScreen(mTempLoc);

            if (rawX > mTempLoc[0] && rawY > mTempLoc[1] &&
                    rawX < mTempLoc[0] + dragBox.getWidth() &&
                    rawY < mTempLoc[1] + dragBox.getHeight()) {

                mItemX = item.getLeft();
                mItemY = item.getTop();

                return touchPos;
            }
        }
    }

    return MISS;
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:37,代码来源:DragSortController.java

示例15: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
    if ((mDragListener != null || mDropListener != null) && mDragView != null) {
        int action = ev.getAction();
        switch (action) {
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                Rect r = mTempRect;
                mDragView.getDrawingRect(r);
                stopDragging();
                if (mDropListener != null && mDragPos >= 0 && mDragPos < getCount()) {
                    mDropListener.drop(mFirstDragPos, mDragPos);
                }
                unExpandViews(false);
                break;

            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_MOVE:
                int x = (int) ev.getX();
                int y = (int) ev.getY();
                dragView(x, y);
                int itemnum = getItemForPosition(y);
                if (itemnum >= 0) {
                    if (action == MotionEvent.ACTION_DOWN || itemnum != mDragPos) {
                        if (mDragListener != null) {
                            mDragListener.drag(mDragPos, itemnum);
                        }
                        mDragPos = itemnum;
                        doExpansion();
                    }
                    int speed = 0;
                    adjustScrollBounds(y);
                    if (y > mLowerBound) {
                        // scroll the list up a bit
                        speed = y > (mHeight + mLowerBound) / 2 ? 16 : 4;
                    } else if (y < mUpperBound) {
                        // scroll the list down a bit
                        speed = y < mUpperBound / 2 ? -16 : -4;
                    }
                    if (speed != 0) {
                        int ref = pointToPosition(0, mHeight / 2);
                        if (ref == AdapterView.INVALID_POSITION) {
                            // we hit a divider or an invisible view, check
                            // somewhere else
                            ref = pointToPosition(0, mHeight / 2 + getDividerHeight() + 64);
                        }
                        View v = getChildAt(ref - getFirstVisiblePosition());
                        if (v != null) {
                            int pos = v.getTop();
                            setSelectionFromTop(ref, pos - speed);
                        }
                    }
                }
                break;
        }
        return true;
    }
    return super.onTouchEvent(ev);
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:59,代码来源:TouchInterceptor.java


注:本文中的android.widget.AdapterView.INVALID_POSITION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。