Programming/Android

화면 아무대나 터치시 이벤트 발생시키기

사천y 2011. 5. 2. 15:43

public class MobileSOS extends Activity 
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mobilesos);
        
    }
    //Touch Event Source
        @Override
public boolean onTouchEvent(MotionEvent event) 
{
if( event.getAction() == MotionEvent.ACTION_DOWN )
{
//터치 발생시 동작
return true;
}
return true;
}
}
 
진하게 표시된 부분이 터치시 발생되는 이벤트를 작성하면 된다.