EditView控件
一、功能简介:
它允许用户在控件里输入和编 辑内容,并可以在程序中对这些内容进行处理。EditText的应用场景应该算是非常普遍了, 发短信、发微博、聊 QQ等等,在进行这些操作时,你不得不使用到 EditText。
二、创建textView文件:
以下是在layout.xml布局文件中的创建EditView空间的一段代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Type something here"
android:maxLines="2" />
</LinearLayout>
1. 属性说明:
1.1 android:id=”@+id/editview” 指定id
1.2 android:layout_width=”match_parent” 指定宽度
1.3 android:layout_height=”wrap_content” 指定高度
1.4 android:hint=”Type something here” 提示内容
1.5 android:maxLines=”2” 指定最大行数为两行
1. hint属性值说明:
提示内容,可见,但无效果
2. maxLines属性:
文本超过最大行数时,会自动滚动。无此设定,EditView控件将一直拉长
三、EditView控件的接口
EditView各个事件的接口说明,以及代码操作
1. 接口说明:
自行百度,自行查看手册
2.代码实现:
问题:
无
原因:
无
效果:
maxLines属性不设置:
设置maxLines = 2: