开发者

Workaround to android:singleLine for items in a ListView without sacrificing itemClickListening functionality

开发者 https://www.devze.com 2023-03-23 04:40 出处:网络
Due to this feature in Lis开发者_Go百科tViews, items cannot gain focus if you want ListView to be able to listen to click events through onItemClick or onListItemClick. Now this is a problem if you wa

Due to this feature in Lis开发者_Go百科tViews, items cannot gain focus if you want ListView to be able to listen to click events through onItemClick or onListItemClick. Now this is a problem if you want a TextView in an item to be single-lined at the same time. Because if you set android:inputType="text", the TextView somehow becomes "clickable", thus gaining focus.

I'm currently using android:singleLine="true" as a workaround, but it is listed as depreciated. Are there any "legit" or non-depreciating methods in doing this.


Try..........

android:maxLines


inputType really makes more sense for EditText. If you really want to use it, can't you just set android:clickable="false" and android:focusable="false"?

Also, look into android:ellipsize if you don't like the first solution.

0

精彩评论

暂无评论...
验证码 换一张
取 消