如何将表格布局添加到ExpandableListView作为一个子项。 [英] How to add a table layout to ExpandableListView as a child item.

查看:81
本文介绍了如何将表格布局添加到ExpandableListView作为一个子项。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个表格布局,以ExpandableListView添加为一个子项。这样,当我们点击组数据的适配器显示表布局。

I want to add a table layout to ExpandableListView as a child item. so that when we click on group data its adaptor shows a table layout.

感谢

推荐答案

在BaseExpandableListView子视图

The child view in BaseExpandableListView

    @Override
public View getChildView( int groupPosition,  int childPosition,
         boolean isLastChild,  View convertView,  ViewGroup parent) {
    TableLayout layout = new TableLayout(this.context);
    layout.setStretchAllColumns(true);
    TableRow tr1 = null;
    if(groupPosition==0){
        Toast.makeText(context, "text in if"+convertView, Toast.LENGTH_SHORT).show();
                if(childPosition==0){             
                     tr1 =new TableRow(this.context);
                     TextView tv = new TextView(this.context);
                    tv.setText("one");
                    tv.setTextColor(Color.YELLOW);                              
                    tr1.addView(tv);
                    layout.addView(tr1);
                }
                if(childPosition==1){
                     tr1 =new TableRow(this.context);
                     TextView tv = new TextView(this.context);
                    tv.setText("two");
                    tv.setTextColor(Color.YELLOW);                                
                    tr1.addView(tv);
                    layout.addView(tr1);
                }
                if (isLastChild) {
                    if(pos_child==0){
                        layout=getObj();
                        }
                        else if(pos_child==1){
                            TableRow tr3 =new TableRow(this.context);
                            TextView tv = new TextView(this.context);
                            tv.setText("ameta");
                            tr3.addView(tv);
                            layout.addView(tr3);
                        }
                }
    }
    return layout;
}

这篇关于如何将表格布局添加到ExpandableListView作为一个子项。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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