inputType下,使项目未点击 [英] inputType makes item un-clickable
问题描述
我有一个的ListView
,其中每个项目有一个复杂的布局,包含,在某些时候,一个的TextView
与的android:inputType下=TEXT
和的android:ellipsize =金字招牌
。我的问题是的inputType =TEXT
做的的东西的呈现整个ListView项未点击。我试过:
I have a ListView
in which each item has a complex layout that contains, at some point, a TextView
with android:inputType="text"
and android:ellipsize="marquee"
. My problem is that inputType="text"
does something that renders the whole listview item un-clickable. I've tried:
-
的android:descendantFocusability =blocksDescendants
在最上面的布局的项目, -
机器人:可聚焦=FALSE
在的TextView
本身 -
的android:focusableInTouchMode =FALSE
在的TextView
本身 -
的android:点击=FALSE
在的TextView
本身 -
机器人:编辑=假
在的TextView
本身 。
android:descendantFocusability="blocksDescendants"
on the top-most layout of an item,android:focusable="false"
on theTextView
itself,android:focusableInTouchMode="false"
on theTextView
itself,android:clickable="false"
on theTextView
itself,android:editable="false"
on theTextView
itself.
毫无效果。
为什么我使用的原因的android:inputType下=上
直插式和的TextView
是使之成为单一的文字的android:ellipsize =金字招牌
实际工作。我做我的家庭作业:
The reason why I use android:inputType="text"
on a TextView
is so that it becomes single-line and android:ellipsize="marquee"
actually works. I've done my homework:
-
的android:SINGLELINE
是pcated德$ P $ * -
的android:行=1
的建议<一href=\"http://stackoverflow.com/questions/3354589/using-inputtype-on-a-textview-in-a-list-item-layout\">here,不工作,文本还是包装,只是你不会看到第二行,所以字幕效果不会出现。
android:singleLine
is deprecated*android:lines="1"
, as suggested here, doesn't work, the text still wraps, you just don't get to see the second line, so the marquee effect does not appear.
*是吗?在Eclipse我的Ctrl +空格键说,这大约的android:SINGLELINE
(重点煤矿):
* or is it? My Ctrl+Space in Eclipse says this about android:singleLine
(emphasis mine):
约束的文本到单个水平滚动线代替
让它换到多行,和垫款集中,而不是
插入时你preSS回车键换行。 * 德precated :
此属性德precated并且由textMultiLine取代
国旗在inputType下属性。改变时要小心
现有的布局,为singeLine的默认值是假的(多
行模式),但是如果你指定的inputType任何值,默认
是单行模式。 (如果同时SINGLELINE和inputType下属性
被发现时,inputType下标志将覆盖的值
单线。)。 [布尔]
Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. * Deprecated: This attribute is deprecated and is replaced by the textMultiLine flag in the inputType attribute. Use caution when altering existing layouts, as the default value of singeLine is false (multi- line mode), but if you specify any value for inputType, the default is single-line mode. (If both singleLine and inputType attributes are found, the inputType flags will override the value of singleLine.). [boolean]
不过,的文档不说什么任何德precation。
However, the docs do not say anything about any deprecation.
这是怎么回事?
推荐答案
Actually in the official documentation of R.attr that attribute constant is deprecated.
但是(如前所述),这是矛盾的 TextView的文档页面。而在看相关的方法,设置单行属性时,就相当于:
However (as mentioned) this is contradicting the TextView documentation page. And when looking at the related methods, setting the singleLine attribute is equivalent to :
myTextView.setTransformationMethod(new SingleLineTransformationMethod());
这也太不pcated德$ P $。它是我周围的德precation如何跳舞。
which too isn't deprecated. And it is how i dance around that deprecation.
这篇关于inputType下,使项目未点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!