如何将表格布局添加到ExpandableListView作为一个子项。

编程入门 行业动态 更新时间:2024-10-23 11:26:43
本文介绍了如何将表格布局添加到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作为一个子项。

本文发布于:2023-11-23 15:52:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622020.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作为一个   如何将   表格   布局   ExpandableListView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!