ExpandableListView仅在特定的Button上展开? [英] ExpandableListView expand only on a specific Button?

查看:110
本文介绍了ExpandableListView仅在特定的Button上展开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我正在尝试像Spotify一样创建一个ExpandableListView ...但是我不知道如何禁用LinearLayout使其像按钮一样(展开列表),我已经创建了一个图像,该图像应描述我喜欢什么我希望可以将文本/图片(父级)上的点击作为正常互动进行处理.单击右侧按钮应像在Spotify中一样扩展列表.

well i´m trying to create a ExpandableListView like Spotify it does... But i don´t have any idea how do disable the LinearLayout to act like a button (Expand the list) I have created a image which should describe what i like. I like to have the possibility to handle a click on the text / image (parent) as a normal interaction. A click on the right button should expand the list like in Spotify...

推荐答案

这是ChannelList的onCreate,它扩展了ListFragment.如果调用Fragment,它将存储数据并生成一个新的适配器.

This is the onCreate from the ChannelList which extends ListFragment. It stores the data and generate a new Adapter if the Fragment is called.

@Override   
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
{                               
    m_ListView = new ExpandableListView(getActivity());
    m_ListView.setId(android.R.id.list);

    m_ListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    m_ListView.setMultiChoiceModeListener(m_MultiChoiceModeListener);

    m_ChannelListAdapter = new ChannelListAdapter(getActivity(), this);
    m_ListView.setAdapter(m_ChannelListAdapter);
    m_ListView.setGroupIndicator(null);
    m_ListView.setOnGroupClickListener(this);

    return m_ListView;
}

在适配器上,我有如下所示的getGroupView方法:

On the Adapter i have the getGroupView Method which look like:

public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {

    if (view == null) 
    {
        view = inflater.inflate(R.layout.layout_channelwithimage, viewGroup, false);
    }

    TextView textView = (TextView) view.findViewById(R.id.labelwithimage);
    textView.setText(getGroup(i).toString());

    ImageButton imbu = (ImageButton) view.findViewById(R.id.imageButton);
    //imbu.setOnClickListener(this);    
    imbu.setFocusable(false);

    return view;
}

因此,如果我在适配器中注册ImageButton,它将从适配器调用onClick.但是在onClick中,我不知道单击了哪个组...如果我未在任何侦听器上注册按钮,它将不会从ChannelList调用onGroupClick ...

So if i register the ImageButton in the adapter it will call the onClick from the adapter. But in the onClick i do not know which group was clicked... If i do not register the button on any listener it will not call the onGroupClick from the ChannelList...

这篇关于ExpandableListView仅在特定的Button上展开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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