关于EditText 的汇总:
1.设置只输入数字
loss_set_num_et.setInputType( InputType.TYPE_CLASS_NUMBER);
2.只能输入数字和小数点
loss_set_num_et.setInputTypee(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
3.在布局xml文件中写法:
<EditText
android:layout_marginTop="35px"
android:id="@+id/loss_set_et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="186px"
android:textSize="24px"
android:maxLength="3"
android:textColor="#333333"
android:background="@null"
android:inputType="number|numberDecimal"
/>
4.EditText设置可以编辑和不可编辑
不可编辑状态:
editText.setFocusable(false);
editText.setFocusableInTouchMode(false);
可编辑状态
editText.setFocusableInTouchMode(true);
editText.setFocusable(true);
editText.requestFocus();
5.设置EditText 只能显示一行
xml:
android:lines="1"
android:singleLine="true"