如何在Android的一个页面上创建多个微调器?

时间:2011-08-18 10:03:21

标签: android spinner

我见过很多关于如何制作微调器的教程,但它们每页只显示一个。当我尝试插入2时,第二个只是不起作用。我以前没有Android编程知识,所以也许我只是把第二个微调代码放在错误的地方。我可以在代码示例中使用一些帮助。

我已经尝试了5次,但我似乎无法在此处发布我的代码,但它只是一个简单的代码,用于一个微调器

谢谢!

编辑:在这里得到答案:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/Spinner1.html

1 个答案:

答案 0 :(得分:0)

尝试此布局...

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/search_scrvw"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<ScrollView 
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">

    <TableLayout 
        android:id="@+id/search_table"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginTop="50dip"
        android:layout_marginLeft="50dip" >

        <TableRow 
            android:layout_width="wrap_content" 
            android:layout_height="match_parent">
            <TextView 
                android:text="Sex" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" />

            <Spinner 
                android:id="@+id/spnr_srch_sex" 
                android:layout_width="150dip" 
                android:layout_height="wrap_content" />

        </TableRow>

        <TableRow 
            android:layout_width="wrap_content" 
            android:layout_height="match_parent">
            <TextView 
                android:text="Age" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" />

            <Spinner 
                android:id="@+id/spnr_srch_age" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" />

        </TableRow>

        <TableRow 
            android:layout_width="wrap_content" 
            android:layout_height="match_parent">
            <TextView 
                android:text="Country" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" />

            <Spinner 
                android:id="@+id/spnr_srch_country" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" />

        </TableRow>

        <Button
            android:id="@+id/search"
            android:text="Search"
            android:layout_width="100dip"
            android:layout_height="wrap_content" />


    </TableLayout>  


  </ScrollView>
</LinearLayout>