Android的行变为不可点击巴顿 [英] Android Row becomes Unclickable with Button

查看:125
本文介绍了Android的行变为不可点击巴顿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表视图,其中每行有行布局的按钮。然而,这似乎使该行本身无法点击。怎样才能让这两个按钮,排点击?

I have a listView, where each row has a button in the row layout. However, this seems to make the row itself unclickable. How can I make both the button and row clickable?

感谢。

推荐答案

您需要这样的名单上设置itemsCanFocus:

You need to set itemsCanFocus on the list like this:

    mList.setItemsCanFocus(true);

为使按钮点击。然后,你将需要使用自己的适配器和getView返回一个观点是可以点击的,可聚焦。你也将失去默认的亮点状态,所以你需要将它们放回与后台资源。所以做到这一点:

To make the button clickable. Then you will need to use your own adapter and in getView return a view which is Clickable and focusable. You will also lose the default highlight states so you need to put them back in with the background resource. So do this:

    view.setClickable(true);
    view.setFocusable(true);
    view.setBackgroundResource(android.R.drawable.menuitem_background);

要回到你的观点之前,你的看法。

to your view before returning your view.

这篇关于Android的行变为不可点击巴顿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆