2012-01-17 14 views
2

ExpandableListViewにテーブルレイアウトを子アイテムとして追加したいと考えています。グループデータをクリックすると、そのアダプタはテーブルレイアウトを表示します。ExpandableListViewにテーブルレイアウトを子アイテムとして追加する方法。

おかげ

+0

http://stackoverflow.com/questions/8891006/populating-a-list-view-from-another-list-view/ 8891240#8891240私から与えられたこの質問の答えをチェックしてください。 – Sameer

+0

このアイコンはレイアウトを持つ子ビューを持っています。 –

答えて

0

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; 
} 
関連する問題