在列表项布局中的 TextView 上使用 inputType
我做了一个ListActivity。我有一个 xml 文件,它定义了此 Activity 的布局。我还有一个 xml 文件,用于定义该列表中项目的布局。该项目布局内部有 3 个 TextView。如果我将 inputType="text" 属性添加到这些 TextView 之一,则当我在模拟器中运行应用程序时,onListItemClick 处理程序将不再执行。
我注意到 singleLine="true" 已被弃用,这就是为什么我将其切换为 inputType="text"。有谁知道为什么会发生这种情况?
注意:我正在针对 2.1 进行开发,
感谢您的帮助
I've made a ListActivity. I have an xml file that defines the layout for this Activity. I also have an xml file that defines the layout for an item in that list. This item layout has 3 TextViews inside of it. If I add the inputType="text" property to one of these TextViews, the onListItemClick handler no longer executes when I run my application in the emulator.
I noticed that singleLine="true" was deprecated, which is why I switched it out for inputType="text". Does anyone know why this is happening?
Note: I'm developing against 2.1
Thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设置 inputType 可能会导致 TextView 成为 focusable ,并且当 ListView 行中有可聚焦元素时,该行将不再可单击。
InputType 与用户输入文本有关。相当于 singleLine="true" 的是lines="1",而不是 inputType="text"
Setting an inputType probably causes the TextView to be focusable , and when you have a focusable element in a ListView row, the row is no longer clickable.
InputType has to do with users entering text. The equivalent to singleLine="true" would be lines="1", not inputType="text"
我也有同样的问题。我通过将 textview 的属性设置为可聚焦的 false 解决了这个问题。
android:focusable="false"
希望这对某人有用,因为 singleLine 属性已被弃用,而 inputType 文本是首选。
I had the same problem. I had resolved this issue by making textview's property focusable, false.
android:focusable="false"
Hope this would be useful to someone, as singleLine property is deprecated and inputType text is preferred.