Android-定制的键盘按键和操作 [英] Android - customized keyboard key and action

查看:173
本文介绍了Android-定制的键盘按键和操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您拥有Android手机,那么您无疑会注意到,在某些应用中,键盘布局如何从标准问题变为仅数字,或者具有基于文本字段输入的.com.net特殊按钮类型(例如电话号码).所以我有2个问题:

If you own Android phone you are no doubt have noticed how in the certain apps the keyboard layout can change from the standard issue to digits-only or to have .com or .net special buttons based on the text field input type (e.g. phone number). So I have 2 questions:

  1. 如何触发此自定义?我怀疑这与EditText格式
  2. 有关
  3. 如果我想添加一些自定义按钮以注入特定图案,是否可以更进一步?假设我有一个AND按钮,当按下该按钮时,会将所有大写的"AND"添加空格,并将其添加到文本字段.能做到吗?
  4. 我不是要问的是如何捕获onKeyPress事件中的某些组合键,然后使用模式填充文本字段-我已经非常知道该怎么做了.
  1. how to trigger this customization? I suspect it has to do with EditText format
  2. Can this be taken even further if I want to add some custom buttons to inject a specific pattern? Say I would have an AND button which when pressed will add all uppercase " AND " surrounded by spaces to the text field. Can this be done?
  3. What I'm not asking is how to capture some key combination in onKeyPress event and then populate text field with a pattern - I pretty much know how to do that already.

推荐答案

它由android:inputType XML属性(或setInputType()方法)控制.

It is controlled by the android:inputType XML attribute (or the setInputType() method).

有关可用选项的信息,请参见 XML属性对象的方法.

For info on the available options see the pages for the XML attribute or the 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会给您以下信息:

whereas changing the inputType to textEmailAddress will give you this:

托管

您可以按此处所述自定义操作"按钮. a>,但我不认为目前无法进行键盘的完全自定义,但是我可能是错的.

You can customize the "action" button as explained here, but I don't believe there's any way to do full customization of keyboards at this time, but I could be wrong.

这篇关于Android-定制的键盘按键和操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆