|
¡û ¤Ï¤¸¤á¤Ë
¥æ¡¼¥¶¤ÈÂÐÏ乤륢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¤È¤Ã¤Æ¡¢¥æ¡¼¥¶ÆþÎϤò¼õ¤±ÉÕ¤±¤ë¤³¤È¤ÏÈó¾ï¤Ë½ÅÍפʵ¡Ç½¤Ç¤¹¡£¤È¤¤¤¦¤«¡¢ÆþÎϤò¼õ¤±ÉÕ¤±¤é¤ì¤Ê¤«¤Ã¤¿¤éÂÐÏÃ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ïºî¤ì¤Þ¤»¤ó¡£
¤³¤³¤Ç¤Ï¥æ¡¼¥¶ÆþÎϤΤ¦¤Á¡¢¥¡¼ÆþÎϤˤĤ¤¤Æ¸¡½Ð¤·¤ÆÂбþ¤¹¤ëÊýË¡¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£
¡û ¥¡¼¥¤¥Ù¥ó¥È¤È¥¡¼¥³¡¼¥É
Android ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢¥¡¼ÆþÎÏ¤Ï android.view.KeyEvent ¤È¤·¤Æɽ¸½¤µ¤ì¤Þ¤¹¡£¤³¤Î KeyEvent ¤Ï¡¢android.view.View ¥¯¥é¥¹¤Î onKeyDown() ¤ª¤è¤Ó onKeyUp() ¥á¥½¥Ã¥É¤òÄ̤·¤Æ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ËÄÌÃΤµ¤ì¤Þ¤¹¡£
public boolean View#onKeyDown(int keyCode, KeyEvent event); public boolean View#onKeyup(int keyCode, KeyEvent event);
¤³¤ì¤é¤Î¥á¥½¥Ã¥É¤Ë¤Ï¡¢Á°½Ò¤Î KeyEvent ¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ÈƱ»þ¤Ë¡¢²¡¤µ¤ì¤¿¥¡¼¤òɽ¤¹¥¡¼¥³¡¼¥É¤¬°ú¿ô¤È¤·¤ÆÅϤµ¤ì¤Þ¤¹¡£¥¡¼¥³¡¼¥É¤Ï KeyEvent#getKeyCode() ¤ò»È¤Ã¤Æ¼è¤ê½Ð¤¹¤³¤È¤â²Äǽ¤Ç¤¹¡£API ¥É¥¥å¥á¥ó¥È¤ÇÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¥¡¼¥³¡¼¥ÉÄê¿ô¡ÊKEYCODE_¤Ç»Ï¤Þ¤ë¥á¥ó¥Ð¡Ë¤ò³Îǧ½ÐÍè¤Þ¤¹¡£
¤Þ¤¿¡¢ALT ¥¡¼¤¬²¡¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤Ï
public final boolean KeyEvent#isAltPressed();
¤ò»È¤Ã¤ÆÄ´¤Ù¤ë¤³¤È¤â¤Ç¤¤Þ¤¹¡£¤½¤Î¾¤Ë¤â¿§¡¹¤Ê¥á¥½¥Ã¥É¤¬ android.view.KeyEvent ¥¯¥é¥¹¤Ë¤ÏÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢°ìÅÙ API ¥É¥¥å¥á¥ó¥È¤òį¤á¤Æ¤ß¤Æ²¼¤µ¤¤¡£
¤³¤ì¤é¤Î KeyEvent ¤Ï¡¢¥½¥Õ¥È¥¦¥§¥¢¥¡¼¥Ü¡¼¥É¤Î¾ì¹ç¤ÏÄ̾ï¤ÏÀ¸À®¤µ¤ì¤Ê¤¤ÍͤǤ¹(API ¥É¥¥å¥á¥ó¥È¤Ë¤è¤ë)¡£¥½¥Õ¥È¥¦¥§¥¢¥¡¼¥Ü¡¼¥É¤Î¾ì¹ç¤Ë¤Ï¤³¤ì¤é¤Î¥¤¥Ù¥ó¥È¤Ë°Í¸¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¤È¤¢¤ê¤Þ¤¹¡£
¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÈÀâÌÀ
¥¡¼ÆþÎϤò¸¡½Ð¤¹¤ë¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£006keyapp.zip ¤«¤é¥À¥¦¥ó¥í¡¼¥É¤Ç¤¤Þ¤¹¡£¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤«¤é¡¢Á´¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò ¸Ç¤á¤¿ zip ¥Õ¥¡¥¤¥ë¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤â¤Ç¤¤Þ¤¹¡£
¤Ê¤ª¡¢¥½¡¼¥¹¥³¡¼¥É¤Ï SDK Tools 22.0.4 / ¥×¥é¥Ã¥È¥Õ¥©¡¼¥à Android 4.2 ¤Ç¥³¥ó¥Ñ¥¤¥ë²Äǽ¤Ç¤¹¡£local.properties Æâ¤Ë sdk.dir ÊÑ¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢¤³¤³¤Ï´Ä¶°Í¸¤Ë¤Ê¤ê¤Þ¤¹¤Î¤Ç¡¢¤ª»È¤¤¤Î´Ä¶¤Ë¹ç¤ï¤»¤ÆÊѹ¹¤·¤Æ¤¯¤À¤µ¤¤¡£
¥½¡¼¥¹¥³¡¼¥ÉÇÛÉۤϽ¤Àµ BSD ¥é¥¤¥»¥ó¥¹¤Ë½¾¤¤¤Þ¤¹¡Ê¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤ÎÌÈÀÕ»ö¹à¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡Ë¡£
ÇÛÉÛÆâÍƤΥե¡¥¤¥ë¥Ä¥ê¡¼¤Ï¢¤ÎÍͤˤʤê¤Þ¤¹¡£
- 006/
- AndroidManifest.xml
- ant.properties
- bin/
- build.xml
- libs/
- local.properties
- proguard-project.txt
- project.properties
- res/
- drawable-ldpi/ic_launcher.png
- drawable-mdpi/
- ic_launcher.png
- ball.png
- drawable-hdpi/ic_launcher.png
- drawable-xhdpi/ic_launcher.png
- layout/main.xml (̤»ÈÍÑ)
- values/strings.xml
- src/riolab/sample/
- KeyApp.java
- KeyView.java
º£²ó¤Ï res/drawable-mdpi/ball.png ¤òɽ¼¨¤·¤Þ¤¹¡£¥¡¼ÆþÎϤˤè¤Ã¤Æ¡¢¤³¤Î²èÁü¤Îɽ¼¨°ÌÃÖ¤òÊѤ¨¤Æ¤ß¤Þ¤¹¡£
¢ball.png (24x24)
QVGA(320x480:mdpi) ¤Î¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô¤¹¤ë¤È¡¢¢¤ÎÍͤËɽ¼¨¤µ¤ì¤Þ¤·¤¿¡£
JKHL(¾å²¼º¸±¦)¤Î¥¡¼¤ò²¡¤¹/Î¥¤¹¤´¤È¤Ë¡¢¥Ü¡¼¥ë¤¬¾å²¼º¸±¦¤Ë°ÜÆ°¤·¤Þ¤¹¡£DPAD¥¡¼¤Ë¤·¤¿¤«¤Ã¤¿¤Î¤Ç¤¹¤¬¡¢¼«Ê¬¤Î PC ¤Ï¥Æ¥ó¥¡¼¤¬Ìµ¤¯¤Æ¤¦¤Þ¤¯Ç§¼±¤·¤Æ¤¯¤ì¤Ê¤«¤Ã¤¿¤Î¤Ç^^; Æä˲èÌ̳°¤«¤É¤¦¤«¤ÎȽÄê¤Ï¹Ô¤Ã¤Æ¤¤¤Ê¤¤¤¿¤á¡¢²èÌ̳°¤Î¤É¤³¤Þ¤Ç¤â°ÜÆ°¤·¤Á¤ã¤¤¤Þ¤¹¡£
¤³¤³¤Ç¤Ï
- KeyApp.java
- KeyView.java
¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£
- KeyApp.java
1 /* 2 * Copyright (c) 2013, Ryo Ichinose 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * * Neither the name of the auther nor the 14 * names of its contributors may be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 19 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 package riolab.sample; 31 32 import android.app.Activity; 33 import android.os.Bundle; 34 import android.view.Window; 35 36 public class KeyApp extends Activity 37 { 38 /** Called when the activity is first created. */ 39 @Override 40 public void onCreate(Bundle savedInstanceState) 41 { 42 super.onCreate(savedInstanceState); 43 requestWindowFeature(Window.FEATURE_NO_TITLE); 44 setContentView(new KeyView(this)); 45 } 46 }
¤³¤ì¤Þ¤Ç¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Î Activity ¥¯¥é¥¹¤È¡¢ÆäËÊѤï¤ê¤Ï¤¢¤ê¤Þ¤»¤ó¡£
- KeyView.java
1 /* 2 * Copyright (c) 2013, Ryo Ichinose 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * * Neither the name of the auther nor the 14 * names of its contributors may be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 19 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 package riolab.sample; 31 32 import android.content.Context; 33 import android.content.res.Resources; 34 import android.graphics.Bitmap; 35 import android.graphics.Canvas; 36 import android.graphics.Color; 37 import android.graphics.Paint; 38 import android.graphics.drawable.Drawable; 39 import android.view.KeyEvent; 40 import android.view.View; 41 42 public class KeyView extends View 43 { 44 private final Paint paint = new Paint(); 45 private Bitmap bitmap; 46 private int x; 47 private int y; 48 49 public KeyView(Context context) 50 { 51 super(context); 52 setFocusable(true); 53 54 Resources res = context.getResources(); 55 Drawable drawable = res.getDrawable(R.drawable.ball); 56 57 int w = drawable.getIntrinsicWidth(); 58 int h = drawable.getIntrinsicHeight(); 59 60 bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); 61 Canvas canvas = new Canvas(bitmap); 62 63 drawable.setBounds(0, 0, w, h); 64 drawable.draw(canvas); 65 } 66 67 @Override 68 protected void onSizeChanged(int w, int h, int oldw, int oldh) 69 { 70 x = w / 2; 71 y = h / 2; 72 } 73 74 @Override 75 public void onDraw(Canvas canvas) 76 { 77 super.onDraw(canvas); 78 canvas.drawColor(Color.BLUE); 79 canvas.drawBitmap(bitmap, x, y, paint); 80 } 81 82 @Override 83 public boolean onKeyDown(int keyCode, KeyEvent event) 84 { 85 if (processKeyCode(keyCode)) { 86 invalidate(); 87 return true; 88 } 89 90 return super.onKeyDown(keyCode, event); 91 } 92 93 @Override 94 public boolean onKeyUp(int keyCode, KeyEvent event) 95 { 96 if (processKeyCode(keyCode)) { 97 invalidate(); 98 return true; 99 } 100 101 return super.onKeyUp(keyCode, event); 102 } 103 104 private boolean processKeyCode(int keyCode) 105 { 106 if (keyCode == KeyEvent.KEYCODE_K) { 107 y -= 10; 108 return true; 109 } 110 111 if (keyCode == KeyEvent.KEYCODE_L) { 112 x += 10; 113 return true; 114 } 115 116 if (keyCode == KeyEvent.KEYCODE_J) { 117 y += 10; 118 return true; 119 } 120 121 if (keyCode == KeyEvent.KEYCODE_H) { 122 x -= 10; 123 return true; 124 } 125 126 return false; 127 } 128 }
¥¡¼ÆþÎϤ˱þ¤¸¤Æ²èÁü¤Îɽ¼¨°ÌÃÖ¤òÊѤ¨¤ë View ¥¯¥é¥¹¤Ç¤¹¡£²èÁü¤Îɽ¼¨¼«ÂΤˤĤ¤¤Æ¤Ï¡¢LECTURE 5 ²èÁü¤òɽ¼¨¤¹¤ë ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
- 46 ¡Á 47 ¹ÔÌÜ
²èÁü¤Îɽ¼¨°ÌÃÖ¤òÊݸ¤¹¤ëÊÑ¿ô¤Ç¤¹¡£²èÁü¤Îº¸¾å¤Î³Ñ¤òɽ¤·¤Þ¤¹¡£
- 67 ¡Á 72 ¹ÔÌÜ (onSizeChanged())
View ¤Î¥µ¥¤¥º¤¬ÊѤï¤Ã¤¿»þ¤Ë¼Â¹Ô¤µ¤ì¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£ËÜ¥×¥í¥°¥é¥à¤Ç¤Ï¡¢View ¤Î¤Û¤Ü¿¿¤óÃæ¡Êx¡¢y ¤Ï²èÁüº¸¾å¤ÎºÂɸ¤Î¤¿¤á¡¢Àµ³Î¤Ë¤Ï¿¿¤óÃæ¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¤¬¡Ë¤Ë²èÁü¤òɽ¼¨¤¹¤ë¤¿¤á¤Ë¡¢Ëܥ᥽¥Ã¥É¤ò¥ª¡¼¥Ð¥é¥¤¥É¤·¤Æ¤¤¤Þ¤¹¡£
- 74 ¡Á 80 ¹ÔÌÜ (onDraw())
79 ¹ÔÌܤΠcanvas.drawBitmap(bitmap, x, y, paint); ¤Ë¤è¤ê¡¢Êݸ¤·¤Æ¤¢¤ë x/y ¤Î°ÌÃ֤˲èÁü¤òɽ¼¨¤·¤Þ¤¹¡£
- 82 ¡Á 91 ¹ÔÌÜ (onKeyDown())
¥¡¼¤¬²¡¤µ¤ì¤¿ºÝ¤Ë¼Â¹Ô¤µ¤ì¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£KeyEvent ¤ò½èÍý¤·¤¿¾ì¹ç¤Ï true¡¢½èÍý¤·¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï false ¤òÊÖ¤·¤Þ¤¹¡£
¼«ºî¤Î processKeyCode() ¤Ë¤è¤Ã¤Æ¥¡¼¤Ë±þ¤¸¤Æ²èÁü¤Îɽ¼¨°ÌÃÖ¤ò¹¹¿·¤·¡¢View#invalidate() ¤Ë¤Æ²èÌ̤κÆÉÁ²è¤òÂ¥¤·¤Þ¤¹¡£View#invalidate() ¤Ë¤ÏÎΰè»ØÄêͤê/̵¤·¥Ð¡¼¥¸¥ç¥ó¤¬¤¢¤ê¤Þ¤¹¤¬¡¢¤³¤³¤Ç¤ÏÎΰè»ØÄê̵¤·¥Ð¡¼¥¸¥ç¥ó¤ò»È¤¦¤³¤È¤Ç²èÌÌÁ´ÂΤκÆÉÁ²è¤ò»Ø¼¨¤·¤Æ¤¤¤Þ¤¹¡£
View#invalidate() ¤Ï¡¢UI ¥¹¥ì¥Ã¥É¡ÊUI ´ØÏ¢¤Î½èÍý¤ò¹Ô¤¦¥¹¥ì¥Ã¥É¡£¥³¡¼¥ë¥Ð¥Ã¥¯¥á¥½¥Ã¥É¤Ï UI ¥¹¥ì¥Ã¥É¤«¤é¼Â¹Ô¤µ¤ì¤ë¡Ë°Ê³°¤Î¥¹¥ì¥Ã¥É¤«¤é¼Â¹Ô¤·¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£UI ¥¹¥ì¥Ã¥É°Ê³°¤«¤é²èÌ̤κÆÉÁ²è¤ò»Ø¼¨¤¹¤ë¤Ë¤Ï¡¢View#postinvalidate() ¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£
- 93 ¡Á 102 ¹ÔÌÜ (onKeyUp())
¥¡¼¤¬Î¥¤µ¤ì¤¿ºÝ¤Ë¼Â¹Ô¤µ¤ì¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£onKeyDown() ¤ÎÀâÌÀ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡ÊËÜ¥×¥í¥°¥é¥à¤Ç¤Ï¡¢¥¡¼¤ò²¡¤·¤¿¤Î¤«Î¥¤·¤¿¤Î¤«¤Ç¤Ï½èÍý¤ò¶èÊ̤·¤Æ¤¤¤Þ¤»¤ó¡Ë¡£
- 104 ¡Á 127 ¹ÔÌÜ (processKeyCode())
JKHL(¾å²¼º¸±¦)¤¬Áàºî¤µ¤ì¤¿¾ì¹ç¤Ë¡¢²èÁü¤Îɽ¼¨°ÌÃÖ(x/y) ¤ò¹¹¿·¤¹¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£Ëܥ᥽¥Ã¥É¼Â¹Ô¸å¤Ë View#invalidate() ¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ç¡¢¿·¤·¤¤É½¼¨°ÌÃ֤˲èÁü¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
°Ê¾å¤Ç²òÀâ¤Ï½ª¤ï¤ê¤Ç¤¹¡£¼¡²ó¤Ï¡¢Ê£¿ô View ¤òƱ»þ¤Ë²èÌ̤Ëɽ¼¨¤¹¤ë¤¿¤á¤ËɬÍפȤʤ롢¥ì¥¤¥¢¥¦¥È´ÉÍýÍÑ¥¯¥é¥¹¤Ë¤Ä¤¤¤ÆÀâÌÀ¤¹¤ëͽÄê¤Ç¤¹¡£
¡û OnKeyListener ¤ò»È¤Ã¤Æ¥¡¼ÆþÎϽèÍý¤òÀÚ¤ê½Ð¤¹
¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ç¤Ï¡¢View ¥¯¥é¥¹¤Î onKeyDown()/onKeyUp() ¤ò¥ª¡¼¥Ð¥é¥¤¥É¤·¤Æ¥¡¼ÆþÎϤò½èÍý¤·¤Þ¤·¤¿¡£¤³¤ÎÊýË¡¤Ï´Êñ¤Ç¤¹¤¬¡¢¥×¥í¥°¥é¥à¤¬¤¢¤ëÄøÅÙÂ礤¯¤Ê¤Ã¤Æ¤¯¤ë¤È¡¢¥¡¼ÆþÎϽèÍý¤ÏÊ̤Υ¯¥é¥¹¤ËǤ¤»¤Æ¥³¡¼¥É¤ò¤¹¤Ã¤¤ê¤µ¤»¤¿¤¤¤È¤¤¤¦Í׵᤬½Ð¤Æ¤¤¿¤ê¤·¤Þ¤¹¡£
¤³¤ÎÍͤʾì¹ç¤Ë»È¤¨¤ë¤Î¤¬¡¢android.view.View.OnKeyListener ¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ç¤¹¡£OnKeyListener ¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ï¡¢¥¡¼ÆþÎϤò½èÍý¤¹¤ë¥¯¥é¥¹¤¬¼ÂÁõ¤¹¤Ù¤¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ç¡¢¼ÂÁõ¥¯¥é¥¹¤ò View#setOnKeyListener() ¤Ë»ØÄꤹ¤ë¤È¥¡¼¥¤¥Ù¥ó¥È¤¬Å¾Á÷¤µ¤ì¤Þ¤¹¡£
public void View#setOnKeyListener(View#OnKeyListener l);
OnKeyListener ¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥á¥½¥Ã¥É¤Ï¡¢onKey() ¥á¥½¥Ã¥É¤Î¤ß¤Ç¤¹¡£¼ÂÁõ¥¯¥é¥¹¤Ï¡¢Ëܥ᥽¥Ã¥É¤ò¼ÂÁõ¤·¤Þ¤¹¡£
public boolean onKey(View v, int keyCode, KeyEvent event);
KeyEvent ¤¬È¯À¸¤·¤¿ View ¤È¡¢keyCode ¤ª¤è¤Ó KeyEvent ¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤¬°ú¿ô¤Ë¤è¤Ã¤ÆÅÁ¤¨¤é¤ì¤Þ¤¹¡£View#onKeyDown()/onKeyUp() ƱÍÍ¡¢KeyEvent ¤ò½èÍý¤·¤¿¾ì¹ç¤Ï true¡¢½èÍý¤·¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï false ¤òÊÖ¤·¤Þ¤¹¡£¥¡¼¤¬²¡¤µ¤ì¤¿¤Î¤«Î¥¤µ¤ì¤¿¤Î¤«¤Ï¡¢KeyEvent#getAction() ¤Ë¤Æ¼èÆÀ¤·¤Þ¤¹¡£
public final int KeyEvent#getAction();
KeyEvent#getAction() ¥á¥½¥Ã¥É¤Ï¡¢°Ê²¼¤Î¤¤¤º¤ì¤«¤òÊÖ¤·¤Þ¤¹¡£
- KeyEvent#ACTION_DOWN
- KeyEvent#ACTION_UP
- KeyEvent#ACTION_MULTIPLE