它由android:inputType
XML属性(或setInputType()
方法)控制。
有关可用选项的信息,请参阅XML attribute或object's method的页面。
作为一个例子,下面的XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText
android:text="example text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone" />
</LinearLayout>
会给你这个布局:
而改变inputType
到textEmailAddress
会给你这样的:
您可以按照here的说明自定义“操作”按钮,但我不认为现在有什么办法可以完全自定义键盘,但我可能是错的。
非常好,谢谢。你知道是否有可能虚假键盘上虚假的ALT键吗?我可以将HOME按钮指定为ALT吗? – Bostone 2009-11-04 05:39:35
没问题......这是我一直想玩的东西:)我不认为你可以模拟alt键,但是,我可能是错的。应该指出的是,可以从头开始实现自己的键盘(或多或少)。他们有一个例子:http://developer.android.com/guide/samples/SoftKeyboard/index.html – 2009-11-04 21:28:32
了解。尽管实现完全自定义键盘对我的低级应用来说可能有点过分:) – Bostone 2009-11-04 22:51:26