1.Use of EditText component
2.Specific content
How to use this component in layout file or Activity program?
<EditText
android:id="@+id/myedit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入姓名:"
/>
<EditText
android:id="@+id/editname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请输入姓名:"
/>
<EditText
android:id="@+id/editage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numeric="integer"—只能输入数字
/>
<EditText
android:id="@+id/editpassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:password="true"—显示密文
/>
Of course, we can also set the edit box to disable input.
<EditText
android:id="@+id/editname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请输入姓名:"
android:editable="false"—设置不可编辑
/>
Of course, we can also set EditText in the Activity program.
public class EditTextActivity extends Activity {
private EditText editText = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edittext);
this.editText = (EditText) super.findViewById(R.id.editname);
this.editText.setText("中国您好");
this.editText.setEnabled(false);//设置已有内容不可编辑
this.editText.setTextSize(30.0f);//设置字体大小
}
}
3. Summary
(1) The text editing box can realize the user data input function;
(2) The implementation of password relies on: "android:password="true"" attribute.