2011년 9월 7일 수요일

p1) 이벤트 처리 예제

    public void buttonPressProcessingExamples(final ImageButton imageButton) {


this.mPrevButton = imageButton;



imageButton.setOnKeyListener(new View.OnKeyListener() {

public boolean onKey(View viewInstance, int key, KeyEvent event) {

if (key == KeyEvent.KEYCODE_ENTER



key == KeyEvent.KEYCODE_DPAD_CENTER) {

if (event.getRepeatCount() != 0)

return false;



Rect r = new Rect();

viewInstance.getFocusedRect(r);

MotionEvent motionEvent = null;

motionEvent = MotionEvent.obtain(event.getDownTime(),

event.getEventTime(), MotionEvent.ACTION_DOWN,

r.exactCenterX(), r.exactCenterY(),

event.getMetaState());



if (event.getAction() == MotionEvent.ACTION_UP) {

motionEvent.setAction(MotionEvent.ACTION_UP);

}



viewInstance.dispatchTouchEvent(motionEvent);

}



return false;

}

});



imageButton.setOnTouchListener(new View.OnTouchListener() {

public boolean onTouch(View v, MotionEvent event) {

if(bIsSkipFlingEvent == true){

return false;

}

switch (event.getAction()) {

case MotionEvent.ACTION_DOWN:

mGuiHandler.sendEmptyMessageDelayed(EmailServiceControl.ACTION1, 300);

break;



case MotionEvent.ACTION_CANCEL:

if (mGuiHandler.hasMessages(EmailServiceControl.ACTION1)) {

mGuiHandler.removeMessages(EmailServiceControl.ACTION1);

}else{

LongPressAction();

}

break;

}

return false;

}

});



imageButton.setOnFocusChangeListener(new View.OnFocusChangeListener() {

public void onFocusChange(View arg0, boolean hasFocus) {

if(hasFocus==false && mREWLongPressed){

LongPressAction();

}

}

});

}

댓글 없음:

댓글 쓰기

국정원의 댓글 공작을 지탄합니다.

UPBIT is a South Korean company, and people died of suicide cause of coin investment.

 UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...