如何使用不同的屏幕创建可扩展的列表视图

时间:2013-07-30 22:03:41

标签: android

如何创建像此图像http://imgur.com/ShuZhbg这样的可消费Listview?如何创建这个屏幕?它包含三个可消耗的节点(描述包含营养)并显示不同的屏幕,我看到这个例子http://ranfeng0610.blog.163.com/blog/static/1857082842011727111359969/,但它使用listview与所有使用相同的UI我想显示不同的Ui与每个节点我将如何做到这一点?帮助我任何想法或例子?????

                1、main.xml
                  <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
   >
   <!-- 禁用系统自带图标android:groupIndicator="@null" -->
 <ExpandableListView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:groupIndicator="@null"
 android:id="@+id/mExpandableListView"
 />
 </LinearLayout>

  2   、group.xml

 <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation = "horizontal"
    android:layout_width="fill_parent" 
 android:layout_height="fill_parent">
  <ImageView
android:layout_width = "25dip"
android:layout_height = "25dip"
android:layout_marginTop="10dip"
 android:id="@+id/mImageView"
/>
<TextView
  android:id = "@+id/group_tv"
 android:layout_width = "wrap_content"
 android:layout_height = "wrap_content"
  android:paddingLeft = "30px"
 android:paddingBottom = "10px"
  android:textSize = "26sp"/>
</LinearLayout>
 3、child.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation = "horizontal"
 android:layout_width="match_parent"
 android:layout_height="match_parent">
<ImageView
 android:layout_gravity = "center_vertical"
 android:id = "@+id/child_iv"
 android:layout_width = "70px"
 android:layout_height = "70px"
 android:paddingLeft = "30px"
 android:paddingTop = "2px"
 android:paddingBottom = "5px"
 android:src = "@drawable/icon"/>
 <TextView
 android:layout_gravity = "center_vertical"
 android:id = "@+id/child_tv"
 android:layout_width = "fill_parent"
 android:layout_height = "fill_parent"
  android:paddingLeft = "30px"
  android:paddingTop = "10px"
 android:paddingBottom = "5px"
 android:textSize = "30sp"/>
 </LinearLayout>

0 个答案:

没有答案