0

我必须开发一个可扩展列表视图 android 示例。我有一个设计问题。请帮我。我该如何解决这个错误?请参考此屏幕截图:当前 o/p 请参考我的屏幕截图并为此提供解决方案。在此处输入图像描述

我希望应用这种格式:

* Order info
Payment_method:
      Payment_method
Subtotal
      Subtotal
* CustomerInfo
Firstname
      Firstname
Lastname
      Lastname
Phone
      Phone

这里 * 提到了第一组(订单信息)和第二组(客户信息)。在这里,我希望单击第一组,这意味着应该显示 payment_method 和小计。

单击第二组时,应显示名字、姓氏和电话。但在这里我必须运行应用程序并单击第一组,然后成功显示 payment_method 和小计。之后,这里也显示了一些空格。然后我必须点击第二组意味着首先显示一些空格,然后只显示名字,姓氏和电话。我该如何解决这个错误?请给我详细解释。

这是我的布局文件代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
    android:orientation="vertical" >
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    >
   <TextView
    android:id="@+id/payment_method1"
     android:paddingLeft="5px"
     android:textSize="15dip"
     android:text="payment_method"
     android:textStyle="bold"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/> 
   <TextView
    android:id="@+id/payment_method"
     android:paddingLeft="75px"
     android:textSize="15dip"
    android:textColor="#10bcc9"
    android:textStyle="bold"
     android:text="payment_method"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>
   <TextView
    android:id="@+id/subtotal1"
      android:text="subtotal"
     android:paddingLeft="5px"
     android:textSize="15dip"

    android:textStyle="bold"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>
   <TextView
    android:id="@+id/subtotal"
      android:text="subtotal"
     android:paddingLeft="65px"
     android:textSize="15dip"
    android:textColor="#10bcc9"
    android:textStyle="bold"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>
    </LinearLayout>
       <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
     >
                  <TextView
    android:id="@+id/firstname1"
     android:paddingLeft="5px"
     android:textSize="15dip"

    android:textStyle="bold"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/> 
                   <TextView
    android:id="@+id/firstname"
     android:paddingLeft="65px"
     android:textSize="15dip"
    android:textColor="#10bcc9"
    android:textStyle="bold"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>

                  <TextView
    android:id="@+id/lastname1"

     android:paddingLeft="5px"
     android:textSize="15dip"

    android:textStyle="bold"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>
                  <TextView
    android:id="@+id/lastname"

     android:paddingLeft="65px"
     android:textSize="15dip"
    android:textColor="#10bcc9"
    android:textStyle="bold"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>
    <TextView
    android:id="@+id/phone1"
     android:paddingLeft="5px"
     android:textSize="15dip"

    android:textStyle="bold"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/> 
      <TextView
    android:id="@+id/phone"
     android:paddingLeft="65px"
     android:textSize="15dip"
    android:textColor="#10bcc9"
    android:textStyle="bold"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>
      </LinearLayout>


       </LinearLayout>
4

1 回答 1

1

为什么不使用 API 演示?

他们有一些很好的例子来说明如何做到这一点。

检查views/expandandable lists/类别。

当然,您可以按照自己的方式对其进行自定义...

可以在 上找到演示(如果您通过 sdk 管理器下载了它们)SDK_MANAGER_PATH/samples/android-##/ApiDemos,其中 SDK_MANAGER_PATH 是 sdk 管理器的安装路径,## 是示例的 android 目标版本(我通常使用最新的) .

于 2012-09-29T11:51:21.523 回答