當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。