• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >Android > Android 测试自定义纯数字软键盘,android自定义

Android 测试自定义纯数字软键盘,android自定义

作者:网友 字体:[增加 减小] 来源:互联网 时间:2017-05-26

网友通过本文主要向大家介绍了android 自定义软键盘,android 自定义view,android 自定义控件,android 自定义dialog,android 自定义进度条等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

Android 测试自定义纯数字软键盘,android自定义



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <EditText android:id="@+id/editText1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginRight="24dp" android:ems="10" android:inputType="none" > <requestFocus /> </EditText> <android.inputmethodservice.KeyboardView android:id="@+id/keyboardview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginTop="5.0dp" android:background="#ffffffff" android:focusable="true" android:keyBackground="@drawable/calculator_button_bg" android:keyTextColor="@color/black" android:keyTextSize="26.0sp" android:shadowColor="#ffffffff" android:shadowRadius="0.0" android:visibility="gone" /> </RelativeLayout>
hexkbd.xml
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="#ffffffff"
    android:keyHeight="10%p"
    android:keyWidth="100%p" >

    <Row>
        <Key
            android:codes="55"
            android:keyEdgeFlags="left"
            android:keyLabel="7" />
        <Key
            android:codes="56"
            android:keyLabel="8" />
        <Key
            android:codes="57"
            android:keyLabel="9" />
    </Row>
    <Row>
        <Key
            android:codes="52"
            android:keyEdgeFlags="left"
            android:keyLabel="4" />
        <Key
            android:codes="53"
            android:keyLabel="5" />
        <Key
            android:codes="54"
            android:keyLabel="6" />
    </Row>
    <Row>
        <Key
            android:codes="49"
            android:keyEdgeFlags="left"
            android:keyLabel="1" />
        <Key
            android:codes="50"
            android:keyLabel="2" />
        <Key
            android:codes="51"
            android:keyLabel="3" />
    </Row>
    <Row>
        <Key
            android:codes="46"
            android:keyEdgeFlags="left"
            android:keyLabel="." />
        <Key
            android:codes="48"
            android:keyLabel="0" />
        <Key
            android:codes="-5"
            android:isRepeatable="true"
            android:keyIcon="@drawable/sym_keyboard_delete" />
    </Row>

</Keyboard>

 

MainActivity.java
package com.example.yanlei.yl2;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;

public class MainActivity extends Activity implements OnClickListener
{
    CustomKeyboard mCustomKeyboard;
    EditText editText;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        editText = (EditText) findViewById(R.id.editText1);
        mCustomKeyboard = new CustomKeyboard(this, R.id.keyboardview,
                R.xml.hexkbd);

        mCustomKeyboard.registerEditText(R.id.editText1);
    }

    @Override
    public void onClick(View v)
    {
        switch (v.getId())
        {
            default:
                break;
        }
    }
}
 CustomKeyboard.java
package com.example.yanlei.yl2;

import android.app.Activity;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
import android.text.Editable;
import android.text.InputType;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnTouchListener;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

/**
 * When an activity hosts a keyboardView, this class allows several EditText's
 * to register for it.
 *
 * @author Maarten Pennings
 * @date 2012 December 23
 */
class CustomKeyboard
{

    /** A link to the KeyboardView that is used to render this CustomKeyboard. */
    private KeyboardView mKeyboardView;
    /** A link to the activity that hosts the {@link #mKeyboardView}. */
    private Activity mHostActivity;

    /** The key (code) handler. */
    private 



 
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • Android 测试自定义纯数字软键盘,android自定义

相关文章

  • 2017-05-26linux设备驱动程序之时钟管理(2)----又见结构
  • 2017-05-26深入了解Volley如何执行一个Request的流程
  • 2017-05-26手势事件,html5手势事件
  • 2017-05-26Xamarin.Android 的照相機使用,xamarin.android
  • 2017-05-26Kotlin的Lambda表达式以及它们怎样简化Android开发(KAD 07),kotlinlambda
  • 2017-05-26Android 面试题--Service,android--service
  • 2017-05-26Android面试题精选
  • 2017-05-26Android面试题(2),android面试题
  • 2017-05-26Java多线程常见问题,java多线程
  • 2017-05-26Android中使用ViewPager实现屏幕页面切换和页面轮播效果,androidviewpager

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • Android实现按两次back键退出应用,android两次back键
    • Android消息处理机制(Handler、Looper、MessageQueue与Message)
    • Activity 启动模式,activity启动模式
    • 自定义Toast的显示位置和显示内容,自定义toast
    • Android开发8:数据存储(二)——SQLite数据库和ContentProvider的使用,
    • 安卓第十天笔记-fragment,安卓-fragment
    • 依赖ConstraintLayout报错,Could not find *****,Failed to resolve:*****,constraintlayout
    • Android SDK 镜像,androidsdk镜像
    • Android中的 init.rc文件简介,androidinit.rc
    • 添加页面切换动画, 避免冷启动

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有