我正在学习android / java,我正在创建一个进行转换的应用程序。我遇到的问题是,由于用户必须选择要转换的单位和要转换为的单位,因此可以进行许多不同的组合。我需要一个可以确定选择了哪个单位的解决方案,以便我可以使用分配给每个单位的值进行计算。下面是代码。
提前感谢您的任何回应。多姆。
<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="Conversions"
android:textSize="20sp" />
<TextView
android:id="@+id/weight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:text="Weight"
android:textSize="20sp"
android:layout_marginLeft="10dp"/>
<Spinner
android:id="@+id/spin1"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_below="@+id/weight"
>
</Spinner>
<Spinner
android:id="@+id/spin2"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_below="@+id/weight"
android:layout_toRightOf="@id/to">
</Spinner>
<TextView
android:id="@+id/to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/weight"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_toRightOf="@id/spin1"
android:text="-->"
android:textSize="25sp" />
}
}
MMTTMM
相关分类