gpt4 book ai didi

android - 可扩展 ListView android中的按钮

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:22:09 26 4
gpt4 key购买 nike

我有一个带有自定义适配器的 ExpandableListActivity。

如果适配器的自定义行包含 imageViewall,则完成,但如果我将此 View 从 imageView 更改为 imageButton,则可扩展 ListView 不会展开。

有没有什么方法可以放一个可以点击的按钮,并且expandablelist不失去展开的功能?

最佳答案

按钮应该是不可聚焦的。在你的 listView.setOnItemClickListener 中(不是在 xml 布局中!!):

Button button = (Button) view.findViewById(R.id.yourButton); 
//where button is the button on listView, and view is the view of your item on list

button.setFocusable(false); /// THIS IS THE SOLUTION

button.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
//button functionalty ...
}
});

关于android - 可扩展 ListView android中的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9880950/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com