本文介绍了ListView 和 ListView 中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 ListView 中显示一个 Button.目标应该是点击 ListView 行或按钮.

I want to display a Button inside the ListView.The goal should be to click on the ListView line or on the button.

点击显示更多信息的行.单击底部显示的按钮更多按钮.

Click on the line it shows more info.Click on the button it shows at the bottom more buttons.

与 GMAIL 应用相同.

The same as the GMAIL app.

右侧有一个复选框,点击底部的复选框后,会出现按钮栏.

On the right there is a checkbox and after clicking on the checkbox at the bottom, the button bar appears.

我的问题是在将按钮插入 ListView 后,该按钮不可点击.如果我从按钮 llButton.setClickable() 添加到 LinearLayout 它工作.但是,只有按钮.ListView 本身不再对点击做出反应!

My problem is after inserting the button into the ListView, the button is not clickable.If I add the to the LinearLayout from the button llButton.setClickable() it works. But, only the button. The ListView itself doesn't react on clicks anymore!

我已经尝试过这个例子.

和上面一样的问题...

The same issue as above...

推荐答案

如果您使用的是自定义适配器,则在 ListView 中单击按钮将不起作用,因此您应该尝试使用以下代码来检查 OnItemClickListener.

If you are using a custom Adapter the Button click inside a ListView will not work so you should try to use the following code to check for OnItemClickListener.

listId.setOnItemClickListener(new AdapterView.OnItemClickListener() {
   public void onItemClick(AdapterView<?> list, View v, int pos, long id) {
      // Your code for item clicks
   }
});

这篇关于ListView 和 ListView 中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 03:19
查看更多