本文介绍了如何将表格布局添加到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作为一个子项。
发布评论