是否可以在Android中制作可扩展的表格,类似于可扩展列表视图,但子项目采用表格/网格格式。 例如,类似于:http://www.coderzheaven.com/2011/04/10/expandable-listview-in-android-using-simpleexpandablelistadapter-a-simple-example/ ,但子项是图像网格。
到目前为止我已经走了多远(在使用Eclipse Kepler的activity_main.xml中)并坚持下去:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<ExpandableListView
android:id="@+id/expandableListView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
</ExpandableListView>
<ExpandableListView
android:id="@+id/expandableListView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
</ExpandableListView>
<ExpandableListView
android:id="@+id/expandableListView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
</ExpandableListView>
</LinearLayout>
答案 0 :(得分:1)
使用可扩展列表视图并使用ExpandableListAdapter,您可以将子单元格设为TableViews
或GridViews或其他任何内容。
只需夸大您想要的视图:
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this.context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.your_item_with_grid, null);
}
// get your views from convert view here
return convertView;
}
这里有ExpandableListAdapter tutorial