Android Edittext Hint

We can set edittext hint by using edittext ‘android:hint’ property.

Edittext hint is used to display a hint about the edittext.

Example: – When we are creating a login window we will create a textview & editext.

Textview is for input (“Enter the username”).

Editext is for output (“androidpeople”).

By using edittext hint we need not create a textview for input. We can provide input text in edittext hint.

1 <EditTextandroid:id="@+id/EditText01"
2 android:layout_height="wrap_content"
3 android:layout_width="wrap_content"
4 android:hint="Enter about edittext"/>

The Output will look like -

When you start typing in editext the hint will be auto hidden.

Android Edittext Single Line

We can set edittext to be a single line by using the property ‘android:singleLine’.

When we type in more text in edittext it will wrap the content and create another line for the text. To stop creating the new line we need to use edittext ‘android:singleLine’ Property.

Android Edittext Single Line Example:-

1 <EditTextandroid:id="@+id/EditText01"
2 android:layout_height="wrap_content"
3 android:singleLine="true"
4 android:text="Edittext example by www.androidpeople.com"
5 android:layout_width="wrap_content"/>

Here singleline property is true. So it won’t create a new line in edittext.

The Output will look like

Here the text is ”Edittext example by www.androidpeople.com” but it is showing “Edittext example by www.android” as the singleline property is true.

If singleline property is false , the output will look like

edittextsinglelinefalse

Android Edittext Numeric

We can set edittext to only allow integer values using edittext property ‘numeric’.

1 <EditTextandroid:text="435.569"
2 android:id="@+id/EditText01"
3 android:layout_width="wrap_content"
4 android:layout_height="wrap_content"
5 android:numeric="integer|decimal"/>

Here the numeric is both ‘interger & decimal’. So it will accept only the integer & decimal values. We will be unable to type characers in edittext.

We can use only 0-9 & ‘.’in edittext

The Output will look like

edittextnumeric

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Linux curl 命令模拟 POST/GET 请求
  2. 检查进程是否仍在运行
  3. LTP--linux稳定性测试 linux性能测试 ltp
  4. Linux Shell编程参考大全
  5. 高级Linux工程师常用软件清单
  6. linux系统更改目录和文件的权限总结
  7. linux基本操作(2)
  8. Linux-HA 入门指南(引用)
  9. Centos 7 利用LVM实现动态扩容
  10. linux下vim配置以及一些常用的快捷键