2012-07-10 96 views

回答

4

您可以使用DecimalFormat

DecimalFormat format = new DecimalFormat("##.#"); 
String formattedText = format.format(025.0); 
editText.setText(formattedText); 

您將獲得導致EditText25.0

+0

感謝這工作 – Newton 2014-04-08 11:31:29

4

可以將其設置在XML文件中。像

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/imageView1" 
    android:layout_below="@+id/imageView1" 
    android:layout_marginLeft="20dp" 
    android:layout_marginTop="54dp" 
    android:ems="10" 
    android:inputType="numberDecimal" > 
相關問題