BaseExpandableListAdapter - 的onclick禁用无儿童groupitems [英] BaseExpandableListAdapter - disable onclick for groupitems with no childrens

查看:186
本文介绍了BaseExpandableListAdapter - 的onclick禁用无儿童groupitems的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实施一项ExpandableListAdapter。

I'm working on implementing an ExpandableListAdapter.

使用情况:

我有我想要添加到无子女的扩展列表组项目。问题是,每一个组项目,可以点击,即使它们包含没有孩子。

I have group items I want to add to the Expandable list with no children. Problem is that every group item can be clicked on, even if they contain no children.

有没有一种方法来禁用/灰色,可扩展按钮,指示它包含没有孩子的用户?

Is there a way to disable/grey out the expandable button to indicate for the user that it contains no children?

目前,我已经实现了:

public void onGroupExpanded(int groupPosition) {
    if (!containsChildren(groupPosition)) {
        Toast.makeText(context, context.getString(R.string.err_no_children), Toast.LENGTH_LONG).show();
    }
}

我宁愿有一个视觉上面(禁用/灰色,扩展按钮)一样,且有这个面包显示,如果他们点击它。因为那一刻,你可以点击groupItem,它试图扩大只是零项目,看起来傻?或者,这是默认的好MMI [1]的行为呢?

I'd rather have a visual as mentioned above (disable/grey out the expandable button) and have this Toast to show up if they click it. Because the moment you can click the groupItem, it tries to just expand zero items, which looks silly? Or is this default good MMI[1] behavior?

[1] http://en.wikipedia.org/wiki/Man-machine_interface

推荐答案

我已经使出关闭使用该组指标(在 ExpandableListActivity ,手工做你列出,如果你有一个定期的活动):

I have resorted to turning off the group indicators using (in an ExpandableListActivity, do it manually on your list if you have a regular Activity):

getExpandableListView().setGroupIndicator(null);

然后在你正在实施检查,看看,如果你是对组做一个视图具有任何子你的 getGroupView()方法(我用一个列表对矿山所以其相当直线前进)和风格小组的意见相应列表(使自己的扩展按钮可能)。你可能要玩的家长和convertView设置,看看有什么最适合你。

Then in your getGroupView() method that you are implementing check to see if the group you are about to make a view for has any children (I am using a List of Lists for mine so its rather straight forward) and style the group's view accordingly (make your own expander-button maybe). You might have to play around with the parent and convertView settings to see what works best for you.

    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {

        convertView = inflater.inflate(
                android.R.layout.simple_expandable_list_item_1, parent,
                false);

        if (groups.get(groupPosition).getMuscles().size() == 0) {
            convertView.setEnabled(false); //Greys out group name
        } 

这篇关于BaseExpandableListAdapter - 的onclick禁用无儿童groupitems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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