技术开发 频道

Android onKeyDown与Layout坐标交互

  111 new AbsoluteLayout.LayoutParams

  112 (intWidth,intHeight,intButtonX,intButtonY)

  113 );

  114 }

  115

  116 /* 点击DPAD上按键时事件处理 */

  117 public void MoveButtonUp()

  118 {

  119 intButtonY = intButtonY-intShift;

  120 /* 预防按钮到达下边界时的处理 */

  121 if(intButtonY<0)

  122 {

  123 intButtonY = 0;

  124 }

  125 mButton01.setLayoutParams

  126 (

  127 new AbsoluteLayout.LayoutParams

  128 (intWidth,intHeight,intButtonX,intButtonY)

  129 );

  130 }

  131

  132 /* 点击DPAD下按键时事件处理 */

  133 public void MoveButtonDown()

  134 {

  135 intButtonY = intButtonY+intShift;

  136 /* 预防按钮到达下边界时的处理 */

  137 if(intButtonY>(intScreenY-intHeight))

  138 {

  139 intButtonY = intScreenX-intHeight;

  140 }

  141 mButton01.setLayoutParams

  142 (

  143 new AbsoluteLayout.LayoutParams

  144 (intWidth,intHeight,intButtonX,intButtonY)

  145 );

  146 }

  147

  148 /* 点击DPAD左按键时事件处理 */

  149 public void MoveButtonLeft()

  150 {

  151 intButtonX = intButtonX-intShift;

  152 /* 预防按钮到达左边界时的处理 */

  153 if(intButtonX<0)

  154 {

  155 intButtonX = 0;

  156 }

  157 mButton01.setLayoutParams

  158 (

  159 new AbsoluteLayout.LayoutParams

  160 (intWidth,intHeight,intButtonX,intButtonY)

  161 );

  162 }

  163

  164 /* 点击DPAD右按键时事件处理 */

  165 public void MoveButtonRight()

  166 {

  167 intButtonX = intButtonX+intShift;

  168 /* 预防按钮到达右边界时的处理 */

0
相关文章