LinearLayout 让子级改变焦点上的选择器状态
我有一个水平布局,其中调度了一些垂直布局。
我想捕获垂直布局的 onFocusEvent,以便当其中一个获得焦点时,垂直布局中包含的图像和文本视图会更改选择器状态。
我尝试通过捕获事件 OnFocusChange 来测试它,如下所示:
LLContact.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View arg0, boolean hasFocus) {
// TODO Auto-generated method stub
if (hasFocus == true) {
// Has Focus
} else {
// Loses focus
}
}
});
但该事件从未被触发。
我将线性布局设置为“FocusableInTouchMode”为 true,将 Focusable 也设置为 true,但似乎该事件从未发生......您有任何线索吗?
提前致谢。
I have a Horizontal Layout in which some vertical layouts are dispatched.
I want to catch the onFocusEvent of my vertical layouts so when one of them gets focus, the image and the textview contained in the vertical layout changes the selector states.
I tried to test it with catching the event OnFocusChange like this :
LLContact.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View arg0, boolean hasFocus) {
// TODO Auto-generated method stub
if (hasFocus == true) {
// Has Focus
} else {
// Loses focus
}
}
});
But the event is never triggered.
I set my linear layout to "FocusableInTouchMode" as true, and Focusable as true as well, but it seems the event never happens ... Do you have any clue ?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要设置管理器 textview 和 imageview 的子级的以下属性:
可聚焦=假;
可点击=假;
focusable in touch mode=false;
并将布局的这些属性设置为 true;
You need to set following properties of childs of manager textview and imageview:
focusable=false;
clickable=false;
focusable in touch mode=false;
and set these properties of layout to true;