android实现虚拟按键实例
来源:互联网 发布:小程序如何连接数据库 编辑:程序博客网 时间:2024/05/01 22:27
上代码:
上layout
- package com.tcl.testandroid;
- import android.app.Activity;
- import android.app.Instrumentation;
- import android.os.Bundle;
- import android.os.Handler;
- import android.view.KeyEvent;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.TextView;
- public class TestAndroidActivity extends Activity {
- private Handler mhHandler = new Handler();
- private Instrumentation in =new Instrumentation();
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- setTheme(android.R.style.Theme_Dialog);
- final Button button = (Button) findViewById(R.id.button1);
- final EditText editText = (EditText) findViewById(R.id.editText);
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- editText.requestFocus();
- new Thread(new Runnable() {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- in.sendKeyDownUpSync(KeyEvent.KEYCODE_F);
- in.sendKeyDownUpSync(KeyEvent.KEYCODE_U);
- in.sendKeyDownUpSync(KeyEvent.KEYCODE_C);
- in.sendKeyDownUpSync(KeyEvent.KEYCODE_K);
- mhHandler.post(new Runnable() {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- button.requestFocus();
- }
- });
- }
- }).start();
- // TODO Auto-generated method stub
- }
- });
- }
- }
上layout
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="wrap_content"
- android:layout_height="wrap_content">
- <Button android:text="Button" android:id="@+id/button1"
- android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- <EditText android:id="@+id/editText" android:layout_height="wrap_content"
- android:layout_width="192dp" />
- </LinearLayout>
0 0
- android实现虚拟按键实例
- Android 虚拟按键驱动实现
- android虚拟按键的实现
- Android 虚拟按键驱动实现
- Android 虚拟按键驱动实现
- Android 虚拟按键驱动实现
- 手机游戏实现Android隐藏虚拟按键
- Mstar虚拟按键触摸屏驱动(芯片msg2133,按键使用android虚拟按键实现,特定报点,识别为按键)
- android虚拟按键
- Android: 发送虚拟按键
- android TP虚拟按键
- android虚拟按键
- android虚拟按键
- android 虚拟按键
- android 隐藏虚拟按键
- android游戏教程:实现触屏控制和虚拟按键
- 全屏实现-去除android盒子底部的虚拟导航按键
- 全屏实现-去除android盒子底部的虚拟导航按键
- 让多个Fragment 切换时不重新实例化
- 将博客搬至CSDN
- MongoDB Java API查询实现
- python 网络编程(TCP & UDP)
- unsupported major.minor version 解决方法
- android实现虚拟按键实例
- 网讯IOS笔试题
- 用hmailserver搭建邮件服务器
- javascript/JS限制用户名只能输入字母和数字下划线
- Makefile
- Android自动化测试初探(四): 模拟键盘鼠标事件(Socket+Instrumentation实现)
- Spring笔记1——控制反转容器
- oracle存储过程和游标的使用
- 单词测试