本文整理汇总了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));
}