2012-01-17 101 views
2

我想將表格佈局添加到ExpandableListView作爲子項目。所以當我們點擊組數據時,它的適配器會顯示一個表格佈局。如何將表格佈局添加到ExpandableListView作爲子項目。

感謝

+0

http://stackoverflow.com/questions/8891006/populating-a-list-view-from-another-list-view/ 8891240#8891240檢查我給出的這個問題的答案。 – Sameer 2012-01-17 12:40:17

+0

這個doesent有一個具有數組的佈局的子視圖 – 2012-01-17 13:24:34

回答

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; 
} 
相關問題