android – inputType使项目不可点击

我有一个ListView,其中每个项目都有一个复杂的布局,在某些时候,包含一个带有
android的TextView:inputType =“text”和android:ellipsize =“marquee”.我的问题是inputType =“text”做了一些使整个listview项无法点击的东西.我试过了:

> android:descendantFocusability =“blocksDescendants”在项目的最顶层布局上,
TextView本身> android:focusable =“false”,
在TextView本身上安装android:focusableInTouchMode =“false”,
TextView本身> android:clickable =“false”,
TextView本身> android:editable =“false”.

没有任何效果.

我在TextView上使用android:inputType =“text”的原因是它变成单行并且android:ellipsize =“marquee”实际上有效.我做完了我的作业:

> android:singleLine已被弃用*
> android:lines =“1”,如建议here,不起作用,文本仍然包装,你只是没有看到第二行,所以没有出现选框效果.

*或者是吗?我在Eclipse中的Ctrl空间说这个关于android:singleLine(强调我的):

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]

但是,the docs对任何弃用都没有任何说明.

这里发生了什么?

最佳答案 实际上在
the official documentation of R.attr中,不推荐使用属性常量.

但是(如上所述)这与the TextView documentation page相矛盾.在查看相关方法时,设置singleLine属性相当于:

myTextView.setTransformationMethod(new SingleLineTransformationMethod());

这也没有被弃用.这就是我如何围绕这种贬值跳舞的方式.

点赞