admin 管理员组

文章数量: 1086019


2024年3月9日发(作者:headspace中文官网)

android输入法01:SoftKeyboard源码解析02

本篇为SoftKeyboard源代码注释。

1、LatinKeyboard

[java] view plaincopy

1.

2.

3.

4.

5.

6.

7.

8.

public class LatinKeyboard extends Keyboard {

private Key mEnterKey;

public LatinKeyboard(Context context, int xmlLayoutResId) {

super(context, xmlLayoutResId);

Log.i("mytest", "LatinKeyboard_LatinKeyboard");

}

9.

10. public LatinKeyboard(Context context, int layoutTemplateResId,

11. CharSequence characters, int columns, int horizontalPadding

) {

12. super(context, layoutTemplateResId, characters, columns, horizo

ntalPadding);

13. Log.i("mytest", "LatinKeyboard_LatinKeyboard");

14. }

15.

16. /*

17. * 描绘键盘时候(由构造函数 )自动调用

18. * */

19. @Override

20. protected Key createKeyFromXml(Resources res, Row parent, int x, in

t y,

21. XmlResourceParser parser) {

22. Log.i("mytest", "LatinKeyboard_createKeyFromXml");

23. Key key = new LatinKey(res, parent, x, y, parser);

24. //重载的目的,好像仅仅是为了记录回车键的值而已(以Key型记录)

25. //无非就是想对回车键做改观

26. if ([0] == 10) {

27. mEnterKey = key;

28. }

29. return key;

30. }

31.

32. /**

33. * This looks at the ime options given by the current editor, to se

t the

34. * appropriate label on the keyboard's enter key (if it has one).

35. */

36. void setImeOptions(Resources res, int options) {

37. //在SoftKeyboard的StartInput函数最后用到了

38. //传入了ions类型的options参数。此变量地位与

ype类似。但作用截然不同

39. Log.i("mytest", "LatinKeyboard_setImeOptions");

40. if (mEnterKey == null) {

41. return;

42. }

43. //惊爆:只要加载了EditorInfo的包,就可以使用其中的常量,所熟知的

TextView类中的常量,经过试验也是可以任意使用的,猜测这些都是静态变量

44. switch (options&(_MASK_ACTION|_FLAG

_NO_ENTER_ACTION)) {

45. case _ACTION_GO:

46. eview = null;

47. = null;//把图片设为空,并不代表就是空,只是

下面的Lable可以代替之

48. = t(_go_key);

49. break;

50. case _ACTION_NEXT:

51. eview = null;

52. = null;

53. = t(_next_key);

54. break;

55. case _ACTION_SEARCH:

56. = wable(

57. _keyboard_search);

58. = null;

59. break;

60. case _ACTION_SEND:

61. eview = null;

62. = null;

63. = t(_send_key);

64. break;

65. default:

66. = wable(

67. _keyboard_return);

68. = null;

69. break;

70. }

71. }

72.

73. static class LatinKey extends {

74.

75. public LatinKey(Resources res, parent, int x, int

y, XmlResourceParser parser) {

76. super(res, parent, x, y, parser);

77. Log.i("mytest", "LatinKeyboard_LatinKey");

78. }

79.

80. /**


本文标签: 源码 好像 参数 常量 变量