Using inputType on a TextView in a list item layout

梦想与她 提交于 2019-12-13 03:29:52

问题


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


回答1:


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"




回答2:


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.



来源:https://stackoverflow.com/questions/3354589/using-inputtype-on-a-textview-in-a-list-item-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!