的TextView和Button每一行和onListItemClick在()TextView、Button、onListItemClick

2023-09-12 07:51:41 作者:Surplus(多余)

我有它的一些元素的ListView。每一行都有一个TextView和一个按钮。它看起来是这样的:

I have a ListView with some elements on it. Each row has a TextView and a Button. It looks like this:

|在一排中的某些文本(按钮)|

现在,当我点击这个文本没有任何反应。根本没有一个函数被调用。但是,当我按一下按钮,我可以处理该事件。我用onListItemClick()

Now, when I click on this text nothing happens. Simply no one function is called. But when I click on the button I can handle the event. I use onListItemClick()

所以,我应该用什么来代替这个TextView中要能够处理一个事件(当我点击的文字)?

So what should I use instead of this TextView to be able to handle an event (when I click on the text)?

在此我不得不每行只有一个TextView中,当我点击一排细小的一切工作(onListItemClick()被调用)。

Before this I had only one TextView in each row and when I was clicking on a row everything worked fine (onListItemClick() was called).

感谢你在前进!

推荐答案

添加属性可聚焦=假的TextView ::

<TextView
...
...
        android:focusable="false"
        />

和可能,你需要做同样的你的ListView里面的其他元素。

and probably you will need to do the same to the other elements inside your ListView.