gpt4 book ai didi

java - 我可以将按钮放入微调器中吗

转载 作者:太空宇宙 更新时间:2023-11-04 13:16:23 24 4
gpt4 key购买 nike

我可以在 Spinner 中使用字符串数组但我不知道我是否可以放其他东西?我想将一些按钮放入 Spinner 中,但是当我将一些按钮放入 XML 中时,应用程序崩溃了!!

    <Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner"
android:layout_below="@+id/textView"
android:layout_toRightOf="@+id/textView"
android:layout_toEndOf="@+id/textView"
android:layout_marginTop="125dp" >
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent" />


</Spinner>

这是正确的方法吗或者是什么 ???

最佳答案

这不会起作用,因为这不是将按钮放置在微调器中的方式。

根据定义Spinner是一个下拉菜单,几乎可以采用任何布局。首先,您必须决定旋转行的样式。

例如:

如果您想要 2 个按钮,则必须使用以下内容创建一个布局/spinner_row.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:padding="20dp"
android:layout_height="wrap_content">

<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button" />

<Button
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2" />
</LinearLayout>

看起来像:

Result

然后你必须制作一个适配器,用你想要的数据来适应微调器的每一行。

关于java - 我可以将按钮放入微调器中吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33484214/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com