本文整理匯總了Java中android.widget.RelativeLayout.setFocusableInTouchMode方法的典型用法代碼示例。如果您正苦於以下問題:Java RelativeLayout.setFocusableInTouchMode方法的具體用法?Java RelativeLayout.setFocusableInTouchMode怎麽用?Java RelativeLayout.setFocusableInTouchMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.RelativeLayout
的用法示例。
在下文中一共展示了RelativeLayout.setFocusableInTouchMode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initLayout
import android.widget.RelativeLayout; //導入方法依賴的package包/類
private void initLayout() {
mLayout = new RelativeLayout(this) {
Rect drawingRc = new Rect();
@Override
protected void dispatchDraw(Canvas canvas) {
getDrawingRect(drawingRc);
if ((mXulPageRender != null) && mXulPageRender.beginDraw(canvas, drawingRc)) {
super.dispatchDraw(canvas);
mXulPageRender.endDraw();
} else {
super.dispatchDraw(canvas);
}
synchronized (mRedrawWaitableObject) {
mRedrawWaitableObject.notifyAll();
}
}
@Override
protected void onFocusChanged(boolean gainFocus, int direction,
Rect previouslyFocusedRect) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
if (!gainFocus) {
LogUtil.d(TAG, "focus lost!!!!");
post(new Runnable() {
@Override
public void run() {
LogUtil.d(TAG, "update focus!!!!");
View view = findFocus();
IXulExternalView xulView = null;
if (view != null) {
if (view instanceof IXulExternalView) {
xulView = (IXulExternalView) view;
} else {
ViewParent vp = view.getParent();
while (vp != null && !(vp instanceof IXulExternalView)) {
vp = vp.getParent();
}
if (vp != null) {
xulView = (IXulExternalView) vp;
}
}
}
if (xulView != null) {
XulView customItemByExtView =
mXulPageRender.findCustomItemByExtView(xulView);
mXulPageRender.getLayout().requestFocus(customItemByExtView);
}
}
});
}
}
};
mLayout.setFocusable(true);
mLayout.setFocusableInTouchMode(true);
mLayout.setLayoutParams(new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}