当前位置: 首页 > news >正文

网站开发学习课程企业做网站认证有哪些好处

网站开发学习课程,企业做网站认证有哪些好处,技能培训有哪些科目,游戏登录器列表更新网站建设本文演示用Android Studio写一个最简单的输入法。界面和交互都很简陋#xff0c;只为剔肉留骨#xff0c;彰显写一个Android输入法的要点。 1、打开Android Studio创建项目#xff0c;该项目和普通APP的不同之处在于它不需要添加任何Activity#xff1a;我给该输入法命名为… 本文演示用Android Studio写一个最简单的输入法。界面和交互都很简陋只为剔肉留骨彰显写一个Android输入法的要点。 1、打开Android Studio创建项目该项目和普通APP的不同之处在于它不需要添加任何Activity  我给该输入法命名为AndroidXXIME。 2、修改manifest文件如前文《Android下创建一个输入法》中所说输入法是一个包含IME service的安卓应用程序首先应该在程序的manifest中声明service。我的manifest.xml文件如下 manifest xmlns:androidhttp://schemas.android.com/apk/res/androidpackagecom.binglen.androidxximeapplicationandroid:allowBackuptrueandroid:iconmipmap/ic_launcherandroid:labelstring/app_nameandroid:supportsRtltrueandroid:themestyle/AppThemeservice android:name.AndroidXXIMEandroid:labelstring/xximeandroid:permissionandroid.permission.BIND_INPUT_METHODintent-filteraction android:nameandroid.view.InputMethod //intent-filtermeta-data android:nameandroid.view.im android:resourcexml/method//service/application/manifest 在Android Studio生成application块的尾部添加IME service的声明。第一行粗体字声明需要BIND_INPUT_METHOD权限第二行粗体字创建了一个能够匹配android.view.InputMethod的intent filter第三行粗体字定义了输入法的metadata。 需要注意service android:name必须与后面java文件中的类名保持一致。 接下来创建该service中声明的资源。 3、method.xmlmeta-data里用到了资源xml/method文件该文件中包含了输入法的subtype属性输入法通过该属性定义它所支持的输入模式和语言一个输入法可以包含多个subtype属性。在工程中res下创建xml文件夹把method.xml添加到该文件夹下。method.xml内容如下 ?xml version1.0 encodingutf-8? input-method xmlns:androidhttp://schemas.android.com/apk/res/androidsubtypeandroid:labelstring/subtype_en_USandroid:imeSubtypeLocaleen_USandroid:imeSubtypeModekeyboard / /input-method 关于subtype的属性可以参见InputMethodSubtype label是该subtype的名字 imeSubtypeLocale是该subtype支持的语言类型 imeSubtypeMode是它所支持的模式可以是keyboard或者voice当输入法被调起是系统会把用户选择的mode值传给输入法。 4、stings.xml在这里补上前文引用到的字符串定义 string namexximeXXIME/string string namesubtype_en_USEnglish (US)/string xxime在manifest中定义service的android:label时被引用到该字串用来显示系统“语言和输入法”中本输入法的名字 5、定义键盘布局在res/layout/中添加文件keyboard.xml定义键盘布局内容如下 ?xml version1.0 encodingUTF-8? android.inputmethodservice.KeyboardViewxmlns:androidhttp://schemas.android.com/apk/res/androidandroid:idid/keyboardandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_alignParentBottomtrueandroid:keyPreviewLayout layout/preview / 点击android.inputmethodservice.KeyboardView查看关于它的XML属性其中keyPreviewLayout表示键盘被按下时的布局资源。在res/layout中添加preview.xml如下 ?xml version1.0 encodingutf-8? TextView xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:gravitycenterandroid:background#ffff00 android:textStyleboldandroid:textSize30sp /TextView 里面仅有一个TextView。 前面资源引用的源头都来自manifest文件却不见哪里引用keyboard.xml。答案在后面AndroidXXIME.java文件中onCreateInputView()函数中创建键盘视图和键盘布局时会用到包括下面的qwerty.xml。 6、定义按键信息按键信息定义在Keyboard中其格式形式如下 Keyboardandroid:keyWidth%10pandroid:keyHeight50pxandroid:horizontalGap2pxandroid:verticalGap2px Row android:keyWidth32px Key android:keyLabelA /.../Row.../Keyboard 这是一个嵌套结构其下包含了Row表示一行内部又包含Key表示一个按键每个按键有两个必填属性  · keyLabel按键上显示的文字  · codes该按键代表的Unicode码 我们的按键信息文件在res/xml/qwerty.xml中定义如下 Keyboard xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:keyWidth10%pandroid:horizontalGap0pxandroid:verticalGap0pxandroid:keyHeight60dpRowKey android:codes113 android:keyLabelq android:keyEdgeFlagsleft/Key android:codes119 android:keyLabelw/Key android:codes101 android:keyLabele/Key android:codes114 android:keyLabelr/Key android:codes116 android:keyLabelt/Key android:codes121 android:keyLabely/Key android:codes117 android:keyLabelu/Key android:codes105 android:keyLabeli/Key android:codes111 android:keyLabelo/Key android:codes112 android:keyLabelp android:keyEdgeFlagsright//RowRow android:layout_centerHorizontaltrueKey android:codes97 android:keyLabela android:horizontalGap5%p android:keyEdgeFlagsleft/Key android:codes115 android:keyLabels/Key android:codes100 android:keyLabeld/Key android:codes102 android:keyLabelf/Key android:codes103 android:keyLabelg/Key android:codes104 android:keyLabelh/Key android:codes106 android:keyLabelj/Key android:codes107 android:keyLabelk/Key android:codes108 android:keyLabell android:keyEdgeFlagsright//RowRowKey android:codes39 android:keyLabel android:keyEdgeFlagsleft/Key android:codes122 android:keyLabelz/Key android:codes120 android:keyLabelx/Key android:codes99 android:keyLabelc/Key android:codes118 android:keyLabelv/Key android:codes98 android:keyLabelb/Key android:codes110 android:keyLabeln/Key android:codes109 android:keyLabelm/Key android:codes44 android:keyLabel,/Key android:codes46 android:keyLabel. android:keyEdgeFlagsright//RowRow android:rowEdgeFlagsbottomKey android:codes63 android:keyLabel\? android:keyWidth10%p android:keyEdgeFlagsleft/Key android:codes47 android:keyLabel/ android:keyWidth10%p /Key android:codes32 android:keyLabel android:keyWidth40%p android:isRepeatabletrue/Key android:codes-5 android:keyLabelDEL android:keyWidth20%p android:isRepeatabletrue/Key android:codes-4 android:keyLabelDONE android:keyWidth20%p android:keyEdgeFlagsright//Row /Keyboard 其中有一些负值是定义在Keyboard类中的常量。 在字母a键的定义中有android:horizontalGap5%p官方文档解释android:horizontalGap用来定义按键之间的间距其实是与上一个按键之间的距离如果是左边打头的的按键则是与左边缘之间的距离。%p表示在父组件中的尺寸占比。 6、创建服务接下来就需要为输入法创建service和listener了。可以在一个类里完成这两个角色AndroidXXIME类扩展了InputMethodService并实现了KeyboardView.OnKeyboardActionListener接口。该类的定义如下 public class AndroidXXIME extends InputMethodServiceimplements KeyboardView.OnKeyboardActionListener {private KeyboardView keyboardView; // 对应keyboard.xml中定义的KeyboardViewprivate Keyboard keyboard; // 对应qwerty.xml中定义的Keyboard Overridepublic void onPress(int primaryCode) {}Overridepublic void onRelease(int primaryCode) {}Overridepublic void onText(CharSequence text) {}Overridepublic void swipeDown() {}Overridepublic void swipeLeft() {}Overridepublic void swipeRight() {}Overridepublic void swipeUp() {}Overridepublic View onCreateInputView() {// keyboard被创建后将调用onCreateInputView函数keyboardView (KeyboardView)getLayoutInflater().inflate(R.layout.keyboard, null); // 此处使用了keyboard.xmlkeyboard new Keyboard(this, R.xml.qwerty); // 此处使用了qwerty.xmlkeyboardView.setKeyboard(keyboard);keyboardView.setOnKeyboardActionListener(this);return keyboardView;}private void playClick(int keyCode){// 点击按键时播放声音在onKey函数中被调用AudioManager am (AudioManager)getSystemService(AUDIO_SERVICE);switch(keyCode){case 32:am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);break;case Keyboard.KEYCODE_DONE:case 10:am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);break;case Keyboard.KEYCODE_DELETE:am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);break;default: am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);}}Overridepublic void onKey(int primaryCode, int[] keyCodes) {InputConnection ic getCurrentInputConnection();playClick(primaryCode);switch(primaryCode){case Keyboard.KEYCODE_DELETE :ic.deleteSurroundingText(1, 0);break;case Keyboard.KEYCODE_DONE:ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));break;default:char code (char)primaryCode;ic.commitText(String.valueOf(code), 1);}} }   7、运行。具体方法参见《SoftKeyboard在AndroidStudio下的配置和运行》界面如下  该例程代码可参见https://github.com/palanceli/AndroidXXIME/tree/v1 转载于:https://www.cnblogs.com/palance/p/5120048.html
http://www.pierceye.com/news/448970/

相关文章:

  • 郑州快速建站公司合肥学做网站app的学校
  • 除了做视频网站还能做什么网站wordpress手机站如何做
  • 域名注册最好的网站人才网站
  • 网站建设咨询云尚网络中铁十二局出国招工
  • 建站系统推荐做网站在哪里做
  • 贵州建设工程招标协会网站wordpress黑白主题
  • 怎么免费建立自己网站扁平化网站设计
  • 可以自己做漫画的网站北仑营销型网站制作
  • 免费网站统计代码有什么样的网站开发
  • 文山微网站建设湖南人工智能建站系统软件
  • 做网站时候编代码wordpress 技术博客主题
  • 成立网站建设工作领导小组seo网站关键词优化软件
  • 怎么兼职做网站网站建设 运维 管理包括
  • 乐清市住房和城乡建设规划局网站专业做家居的网站
  • 做3d打印网站苏州建设工程人才招聘网信息网站
  • 网站建设丂金手指科杰wordpress中logo大小
  • 微餐饮网站建设被老板抓到用公司产品做自己的网站
  • 软件公司网站模板下载定制搭建网站
  • 网站建设实训报告要求怎么做公司门户网站
  • 深圳规划建设局网站wordpress改变访问目录
  • dw怎么做购物网站o2o平台都有哪些
  • 阿里云备案多个网站吗应用商店下载app软件
  • 响应式网站手机端尺寸网站开发培训心得
  • 徐州手机网站开发公司电话江苏五星建设网站
  • 网站建设全包广做短视频素材哪里找
  • 做网站为什么每年都要续费企业官网建站步骤
  • 培训行业门户网站建设方案专业网站运营制作
  • 百度网站两两学一做心得体会江苏专业网站建设费用
  • 做企业网站的架构图网站上的销售怎么做
  • 网站开发思维导图内容淘宝客在百度推广网站么做