本文介绍了如何触发从布局视图选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设你有一个布局视图内的视图,您希望在布局的每个动人的事会影响视图的背景选择。

Suppose you have a view inside a layout view, and you wish that each touching event on the layout would affect the view's background selector.

例如,当你触摸的布局,视图的选择会选择STATE_ pressed状态。

for example, when you touch the layout , the selector of the view will choose the state_pressed state.

我读过有关duplicateParentState和addStatesFromChildren,但我认为这是一个什么样我在寻找相反的。

I've read about duplicateParentState and addStatesFromChildren , but I think it's the opposite of what I'm searching for.

我也试过用splitMotionEvents,但它并没有帮助。

I've also tried to use splitMotionEvents, but it didn't help.

你怎么做到这一点?

此外,什么应该在的情况下进行的布局是一个ListView里面(因为在它的项目)?

Also, what should be done in case the layout is inside a listView (as an item within it) ?

推荐答案

考虑你有一个线性布局内的微调。使视图(这里说的微调),以虚假聚焦的财产。与线性布置的onClick调用performClick上视图(在这种情况下,旋转器)。

Consider you have a spinner inside a linear layout. Make focusable property of view(here that is spinner) to false. And onClick of linear layout call performClick on view(spinner in this case).

编辑:

在它是否关注线性布局的焦点变化监听器,调用requestFocus的上视图。
您可以按照同样的方法将视其他国家

In focus Change Listener of linear layout if it has focus, call requestFocus on view.You can follow same method to other states of view

另一种方法:

不应用任何选择布局(在这种情况下的LinearLayout),并添加您要查看(在这种情况下微调)任何选择。对于视图中添加此参数

do not apply any selector to layout(linearlayout in this case) and add whatever selector you want to view(spinner in this case). For view add this parameter

android:duplicateParentState="true"

这篇关于如何触发从布局视图选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 08:29
查看更多