亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何處理用戶的潛在選擇

如何處理用戶的潛在選擇

暮色呼如 2022-08-03 15:48:13
我正在學習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" />    }}
查看完整描述

1 回答

?
MMTTMM

TA貢獻1869條經驗 獲得超4個贊

我正在設想一個應用程序,它可以在不同的測量單位(英尺,英里,米等)之間轉換輸入距離。以下是我要做的:

創建兩個雙精度類型的變量,分別名為 和 。當用戶從每個微調器中選擇一個選項時,這將設置相應的轉換因子值。inputConversionFactoroutputConversionFactor

輸入輸入距離時,請使用 在內部將此距離轉換為米。然后用于從儀表轉換為所需的輸出單位。inputConversionFactoroutputConversionFactor

通過這種方式,您將問題分解為兩個獨立的步驟。您不必擔心如何在任意兩個任意單位之間進行轉換,因為您始終將輸入轉換為米,然后將米轉換為輸出單位類型。


查看完整回答
反對 回復 2022-08-03
  • 1 回答
  • 0 關注
  • 100 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號