默认情况下软键盘右下角的按钮为“下一个”,点击会到下一个输入框,保持软键盘

设置 android:imeOptions="actionDone" ,软键盘下方变成“完成”,点击后光标保持在原来的输入框上,并且软键盘关闭

android:imeOptions="actionSend" 软键盘下方变成“发送”,点击后光标移动下一个

 
 
 
在这里设置的imeOptions如何使用呢?如下面的代码,让EditText实现setOnEditorActionListener,在onEditAction方法中actionId就对应我们设置的imeOptions。系统默认的actionId有:EditorInfo.IME_NULL、EditorInfo.IME_ACTION_SEND、EditorInfo.IME_ACTION_DONE等。这样我们就可以根据不同的EditText来实现不同的软键盘右下角功能键。
 
  1. package com.test;
  2. import com.test.main.TestAsyn;
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.view.KeyEvent;
  6. import android.view.inputmethod.EditorInfo;
  7. import android.widget.EditText;
  8. import android.widget.TextView;
  9. import android.widget.TextView.OnEditorActionListener;
  10. import android.widget.Toast;
  11. public class IMFActivity extends Activity implements OnEditorActionListener {
  12. EditText etDefault;
  13. EditText etEmail;
  14. EditText etNumber;
  15. /** Called when the activity is first created. */
  16. @Override
  17. public void onCreate(Bundle savedInstanceState) {
  18. super.onCreate(savedInstanceState);
  19. setContentView(R.layout.imf_layout);
  20. etDefault = (EditText)findViewById(R.id.default_content);
  21. etEmail = (EditText)findViewById(R.id.email_content);
  22. etNumber = (EditText)findViewById(R.id.number_content);
  23. etDefault.setOnEditorActionListener(this);
  24. etEmail.setOnEditorActionListener(this);
  25. etNumber.setOnEditorActionListener(this);
  26. }
  27. @Override
  28. public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
  29. switch(actionId){
  30. case EditorInfo.IME_NULL:
  31. System.out.println("null for default_content: " + v.getText() );
  32. break;
  33. case EditorInfo.IME_ACTION_SEND:
  34. System.out.println("action send for email_content: "  + v.getText());
  35. break;
  36. case EditorInfo.IME_ACTION_DONE:
  37. System.out.println("action done for number_content: "  + v.getText());
  38. break;
  39. }
  40. //Toast.makeText(this, v.getText()+"--" + actionId, Toast.LENGTH_LONG).show();
  41. return true;
  42. }
  43. }
 
xml文件:
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    3. android:layout_width="fill_parent" android:layout_height="fill_parent">
    4. <TableLayout android:layout_width="fill_parent"
    5. android:layout_height="fill_parent">
    6. <TableRow>
    7. <TextView android:text="No special rules" android:id="@+id/TextView01"
    8. android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    9. <EditText android:text="1111111111111" android:id="@+id/default_content"
    10. android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
    11. </TableRow>
    12. <TableRow>
    13. <TextView android:text="Email address:" android:id="@+id/TextView01"
    14. android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    15. <EditText android:text="" android:id="@+id/email_content"
    16. android:layout_width="fill_parent" android:layout_height="wrap_content"
    17. android:inputType="text|textEmailAddress"
    18. android:imeOptions="actionSend"></EditText>
    19. </TableRow>
    20. <TableRow>
    21. <TextView android:text="Signed decimal number:" android:id="@+id/TextView01"
    22. android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    23. <EditText android:text="" android:id="@+id/number_content"
    24. android:layout_width="fill_parent" android:layout_height="wrap_content"
    25. android:inputType="number|numberSigned|numberDecimal"
    26. android:imeOptions="actionDone"></EditText>
    27. </TableRow>
    28. </TableLayout>
    29. </ScrollView>

imeOptions 属性详解的更多相关文章

  1. Android TextView和EditText属性详解

    TextView属性详解: autoLink设置 是否当文本为URL链接/email/电话号码/map时,文本显示为可点击的链接.可选值(none/web /email/phone/map/all) ...

  2. EditText属性详解

    关于EditText属性详解很详细的记录,转过来收着 1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: 把该EditText设为:android:password=" ...

  3. Android textAppearance的属性设置及TextView属性详解

    textAppearance的属性设置 android:textAppearance="?android:attr/textAppearanceSmall" android:tex ...

  4. Android笔记-2-TextView的属性详解

    [Android 基础]TextView的属性详解 android:autoLink :设置是否当文本为URL链接/email/电话号码/map时,文本显示为可点击的链接.可选值(none/web / ...

  5. android:exported 属性详解

    属性详解 标签: android 2015-06-11 17:47 27940人阅读 评论(7) 收藏 举报 分类: Android(95) 项目点滴(25) 昨天在用360扫描应用漏洞时,扫描结果, ...

  6. OutputCache属性详解(一)一Duration、VaryByParam

    目录 OutputCache概念学习 OutputCache属性详解(一) OutputCache属性详解(二) OutputCache属性详解(三) OutputCache属性详解(四)— SqlD ...

  7. OutputCache属性详解(二)一 Location

    目录 OutputCache概念学习 OutputCache属性详解(一) OutputCache属性详解(二) OutputCache属性详解(三) OutputCache属性详解(四)— SqlD ...

  8. OutputCache属性详解(三)— VaryByHeader,VaryByCustom

    目录 OutputCache概念学习 OutputCache属性详解(一) OutputCache属性详解(二) OutputCache属性详解(三) OutputCache属性详解(四)— SqlD ...

  9. OutputCache属性详解(四)— SqlDependency

    目录 OutputCache概念学习 OutputCache属性详解(一) OutputCache属性详解(二) OutputCache属性详解(三) OutputCache属性详解(四)— SqlD ...

随机推荐

  1. Java总结反射

    [案例1]通过一个对象获得完整的包名和类名 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 package Reflect;   /**  * 通过一个对象获得完整的包名和类名 ...

  2. Oracle-记录学习

    --select name,count(id) from work_test group by name having count(id)>1--select upper(name),t.*,l ...

  3. 免费PHP WEB环境套件介绍

    PHPNOW--Apache + PHP + MySQL(windows) easyphp--Apache + PHP + MySQL+phpmyadmin(windows) xampp(中文站点)- ...

  4. web错误

    “/Web”应用程序中的服务器错误. 服务器 'LD-PC' 上的 MSDTC 不可用. 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误 ...

  5. C++实现有向权图的基本操作,界面友好,操作方便,运行流畅

    Ⅰ.功能: .创建图 .展示全图 .添加顶点 .添加边 .删除顶点 .删除边 .查看指定边权值 .修改指定边权值 .输出两点间的所有简单路及路径对应权值 .销毁图 ps:关于9,如果不存在任何简单路, ...

  6. GoAccess日志分析工具使用文档

    ----Sevck 2016/3/4 17:24:13 #1软件说明: GoAccess是一款开源.实时,运行在命令行终端下的web日志分析工具.该工具提供快速.多样的HTTP状态统计,可以令管理员不 ...

  7. java传递和返回对象

    java传递的只是一个引用,一定要注意准确认识在对象传递和赋值时所发生的一切. 事实上,java中的每个对象(除了基本数据类型以外)的标识符都属于指针的一种,但是其使用受到了严格的限制和防范,不仅在编 ...

  8. [数据结构与算法]栈Stack的多种实现

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  9. [SAP ABAP开发技术总结]列表屏幕

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  10. POJ 3104 Drying(二分答案)

    题目链接:http://poj.org/problem?id=3104                                                                  ...