諮詢

2012-08-24 104 views
0

我有小孩的可擴展的ListView諮詢

<ExpandableListView 
    android:id="@+id/expandableListView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" > 
</ExpandableListView> 

,併爲集團

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:paddingBottom="5dip" 
     android:paddingTop="5dip" 
     android:tag="tank" > 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:paddingLeft="6dip" 
      android:text="123" /> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="1000" /> 
    </LinearLayout> 

自定義佈局和自定義佈局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:paddingLeft="25dip" 
      android:text="This is the number" /> 

     <TextView 
      android:id="@+id/text1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center_horizontal" 
      android:text="3.38672" /> 
    </LinearLayout> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/linearLayout2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/linearLayout1" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/hrzntl" 
     android:layout_width="fill_parent" 
     android:layout_height="2dip" 
     android:layout_weight="1" 
     android:background="#696969" /> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/linearLayout3" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/linearLayout2" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center_horizontal" 
      android:text="Strap" 
      android:textStyle="bold" /> 
    </LinearLayout> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/linearLayout4" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/linearLayout3" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center_horizontal" 
      android:text="height" /> 

     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="volume" /> 
    </LinearLayout> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/linearLayout5" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/linearLayout4" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/hrzntl" 
     android:layout_width="fill_parent" 
     android:layout_height="2dip" 
     android:layout_weight="1" 
     android:background="#696969" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/linearLayout5" 
    android:orientation="vertical" > 

    <ListView 
     android:id="@+id/listView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 
    </ListView> 

</LinearLayout> 

和ListView控件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" > 

<TextView 
    android:id="@+id/text1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_horizontal" 
    android:layout_weight="1" 
    android:text="TextView" /> 

<TextView 
    android:id="@+id/text2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:text="TextView" /> 

我怎麼能去延伸BaseExpandableListAdapter自定義類填充此自定義佈局?

public class ExpandableListAdapter extends BaseExpandableListAdapter{ 

@Override 
public Object getChild(int groupPosition, int childPosition) { 
    // TODO Auto-generated method stub 
    return null; 
} 

@Override 
public long getChildId(int groupPosition, int childPosition) { 
    // TODO Auto-generated method stub 
    return 0; 
} 

@Override 
public View getChildView(int groupPosition, int childPosition, 
     boolean isLastChild, View convertView, ViewGroup parent) { 
    // TODO Auto-generated method stub 
    return null; 
} 

@Override 
public int getChildrenCount(int groupPosition) { 
    // TODO Auto-generated method stub 
    return 0; 
} 

@Override 
public Object getGroup(int groupPosition) { 
    // TODO Auto-generated method stub 
    return null; 
} 

@Override 
public int getGroupCount() { 
    // TODO Auto-generated method stub 
    return 0; 
} 

@Override 
public long getGroupId(int groupPosition) { 
    // TODO Auto-generated method stub 
    return 0; 
} 

@Override 
public View getGroupView(int groupPosition, boolean isExpanded, 
     View convertView, ViewGroup parent) { 
    // TODO Auto-generated method stub 
    return null; 
} 

@Override 
public boolean hasStableIds() { 
    // TODO Auto-generated method stub 
    return false; 
} 

@Override 
public boolean isChildSelectable(int groupPosition, int childPosition) { 
    // TODO Auto-generated method stub 
    return false; 
}} 
+1

大量的android.developer.com教程。 giyf也是 – njzk2

回答

0

使用LayoutInflater膨脹和getChildView()回你想你想在getGroupView()該組的佈局和佈局的孩子。