當前位置: 首頁>>代碼示例>>Java>>正文


Java View.getFocusedRect方法代碼示例

本文整理匯總了Java中android.view.View.getFocusedRect方法的典型用法代碼示例。如果您正苦於以下問題:Java View.getFocusedRect方法的具體用法?Java View.getFocusedRect怎麽用?Java View.getFocusedRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.getFocusedRect方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleHorizontalFocusWithinListItem

import android.view.View; //導入方法依賴的package包/類
private boolean handleHorizontalFocusWithinListItem(int direction) {
    if (direction == 33 || direction == 130) {
        int numChildren = getChildCount();
        if (this.mItemsCanFocus && numChildren > 0 && this.mSelectedPosition != -1) {
            View selectedView = getSelectedView();
            if (selectedView != null && selectedView.hasFocus() && (selectedView instanceof ViewGroup)) {
                View currentFocus = selectedView.findFocus();
                View nextFocus = FocusFinder.getInstance().findNextFocus((ViewGroup) selectedView, currentFocus, direction);
                if (nextFocus != null) {
                    currentFocus.getFocusedRect(this.mTempRect);
                    offsetDescendantRectToMyCoords(currentFocus, this.mTempRect);
                    offsetRectIntoDescendantCoords(nextFocus, this.mTempRect);
                    if (nextFocus.requestFocus(direction, this.mTempRect)) {
                        return true;
                    }
                }
                View globalNextFocus = FocusFinder.getInstance().findNextFocus((ViewGroup) getRootView(), currentFocus, direction);
                if (globalNextFocus != null) {
                    return isViewAncestorOf(globalNextFocus, this);
                }
            }
        }
        return false;
    }
    throw new IllegalArgumentException("direction must be one of {View.FOCUS_UP, View.FOCUS_DOWN}");
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:27,代碼來源:HListView.java

示例2: handleHorizontalFocusWithinListItem

import android.view.View; //導入方法依賴的package包/類
/**
 * To avoid horizontal focus searches changing the selected item, we
 * manually focus search within the selected item (as applicable), and
 * prevent focus from jumping to something within another item.
 * 
 * @param direction
 *            one of {View.FOCUS_LEFT, View.FOCUS_RIGHT}
 * @return Whether this consumes the key event.
 */
private boolean handleHorizontalFocusWithinListItem(int direction) {
	// TODO: implement this
	if (direction != View.FOCUS_UP && direction != View.FOCUS_DOWN) {
		throw new IllegalArgumentException("direction must be one of" + " {View.FOCUS_UP, View.FOCUS_DOWN}");
	}

	final int numChildren = getChildCount();
	if (mItemsCanFocus && numChildren > 0 && mSelectedPosition != INVALID_POSITION) {
		final View selectedView = getSelectedView();
		if (selectedView != null && selectedView.hasFocus() && selectedView instanceof ViewGroup) {

			final View currentFocus = selectedView.findFocus();
			final View nextFocus = FocusFinder.getInstance().findNextFocus((ViewGroup) selectedView, currentFocus,
					direction);
			if (nextFocus != null) {
				// do the math to get interesting rect in next focus'
				// coordinates
				currentFocus.getFocusedRect(mTempRect);
				offsetDescendantRectToMyCoords(currentFocus, mTempRect);
				offsetRectIntoDescendantCoords(nextFocus, mTempRect);
				if (nextFocus.requestFocus(direction, mTempRect)) {
					return true;
				}
			}
			// we are blocking the key from being handled (by returning
			// true)
			// if the global result is going to be some other view within
			// this
			// list. this is to acheive the overall goal of having
			// horizontal d-pad navigation remain in the current item.
			final View globalNextFocus = FocusFinder.getInstance().findNextFocus((ViewGroup) getRootView(),
					currentFocus, direction);
			if (globalNextFocus != null) {
				return isViewAncestorOf(globalNextFocus, this);
			}
		}
	}
	return false;
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:49,代碼來源:HListView.java

示例3: getFocusedRect

import android.view.View; //導入方法依賴的package包/類
public void getFocusedRect(Rect r) {
    View view = getSelectedView();
    if (view == null || view.getParent() != this) {
        super.getFocusedRect(r);
        return;
    }
    view.getFocusedRect(r);
    offsetDescendantRectToMyCoords(view, r);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:10,代碼來源:AbsHListView.java

示例4: getFocusedRect

import android.view.View; //導入方法依賴的package包/類
@Override
public void getFocusedRect(Rect r) {
	View view = getSelectedView();
	if (view != null && view.getParent() == this) {
		// the focused rectangle of the selected view offset into the
		// coordinate space of this view.
		view.getFocusedRect(r);
		offsetDescendantRectToMyCoords(view, r);
	} else {
		// otherwise, just the norm
		super.getFocusedRect(r);
	}
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:14,代碼來源:AbsHListView.java

示例5: getFocusedRect

import android.view.View; //導入方法依賴的package包/類
public void getFocusedRect(Rect paramRect) {
	View localView = getSelectedView();
	if (localView != null) {
		localView.getFocusedRect(paramRect);
		offsetDescendantRectToMyCoords(localView, paramRect);
		return;
	}
	super.getFocusedRect(paramRect);
}
 
開發者ID:Evan-Galvin,項目名稱:FreeStreams-TVLauncher,代碼行數:10,代碼來源:FocusedRelativeLayout.java

示例6: getFocusedRect

import android.view.View; //導入方法依賴的package包/類
@Override
public void getFocusedRect(Rect r) {
    View view = getSelectedView();
    if (view != null && view.getParent() == this) {
        // the focused rectangle of the selected view offset into the
        // coordinate space of this view.
        view.getFocusedRect(r);
        offsetDescendantRectToMyCoords(view, r);
    } else {
        // otherwise, just the norm
        super.getFocusedRect(r);
    }
}
 
開發者ID:Shmilyz,項目名稱:Swap,代碼行數:14,代碼來源:PLA_AbsListView.java


注:本文中的android.view.View.getFocusedRect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。