Как добавить макет таблицы в ExpandableListView как дочерний элемент. - PullRequest
2 голосов
/ 17 января 2012

Я хочу добавить макет таблицы в ExpandableListView как дочерний элемент.так что, когда мы нажимаем на данные группы, его адаптер показывает макет таблицы.

Спасибо

1 Ответ

0 голосов
/ 24 января 2012

Дочернее представление в 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;
}
...