본문 바로가기

창고/Backup_2012_0511이전

블랙베리UI TouchEvent

반응형
블랙베리 UI 화면 기본단위 Screen

- Screen 관련 클래스들

[Screen]
 Screen 클래스를 사용하면 화면을 만들고 화면의 UI 구성요소를 배
치하는 레이아웃 관리자를 사용할 수 있습니다. Field 슈퍼 클래스에
있는 상수가 정의하는 스타일을 사용하여 특정 유형의 화면을 정의할
수 있습니다.

[FullScreen]
FullScreen 클래스를 사용하면 UI 구성요소를 표준 세로 레이아웃에
추가할 수 있는 빈 화면을 만들 수 있습니다. 가로, 대각선 등의 다른
레이아웃 스타일을 사용하려면 대신 Screen 클래스를 사용하고 레이
아웃 관리자를 추가할 수 있습니다.
- 게임개발시 이용

[MainScreen]
 MainScreen 클래스를 사용하면 다음 표준 UI 구성요소가 있는 화면
을 만들 수 있습니다.
• 기본 화면 제목(제목 다음에 SeparatorField 가 있음) ( setTitle 메소드 이용 )
• VerticalFieldManager 에 포함된 기본 스크롤 가능 섹션
• 닫기 메뉴 항목이 있는 기본 메뉴
• BlackBerry® 단말기 사용자가 닫기 메뉴 항목을 클릭하거나 Esc 키를 누를 때 화면을 닫는
   기본 닫기 동작

MainScreen 객체를 BlackBerry 단말기 프로그램의 첫 번째 화면에
사용하여 다른 BlackBerry 단말기 프로그램과의 일관성을 유지하는
것을 고려해야 합니다. ( 주로 기본 UI 이용하여 앱을 제작한다면 각 기본 스크린을 담당 )

- 터치 스크린 상호 작용


-. 무압력 클릭 지원여부 확인하는 메소드
DeviceCapability.isTouchClickSupported()
true   = Sure Press 터치스크린
false = 무압력 클릭

-. 터치 스크린 이벤트 테스트

 1 /* MyApp.java */ 2 3 package mypackage; 4 5 import net.rim.device.api.ui.UiApplication; 6 7 /** 8 * This class extends the UiApplication class, providing a 9 * graphical user interface. 10 */ 11 public class MyApp extends UiApplication 12 { 13 /** 14 * Entry point for application 15 * @param args Command line arguments (not used) 16 */ 17 public static void main(String[] args) 18 { 19 // Create a new instance of the application and make the currently 20 // running thread the application's event dispatch thread. 21 MyApp theApp = new MyApp(); 22 theApp.enterEventDispatcher(); 23 } 24 25 26 /** 27 * Creates a new MyApp object 28 */ 29 public MyApp() 30 { 31 // Push a screen onto the UI stack for rendering. 32 pushScreen(new MyScreen()); 33 } 34 } 35

1 /* MyScreen.java */ 2 package mypackage; 3 4 import net.rim.device.api.ui.TouchEvent; 5 import net.rim.device.api.ui.component.Dialog; 6 import net.rim.device.api.ui.container.MainScreen; 7 8 /** 9 * A class extending the MainScreen class, which provides default standard 10 * behavior for BlackBerry GUI applications. 11 */ 12 public final class MyScreen extends MainScreen 13 { 14 /** 15 * Creates a new MyScreen object 16 */ 17 public MyScreen() 18 { 19 // Set the displayed title of the screen 20 setTitle("MyTitle"); 21 } 22 23 protected boolean touchEvent(TouchEvent message) { 24 // TODO Auto-generated method stub 25 switch(message.getEvent()) 26 { 27 case TouchEvent.DOWN: 28 Dialog.alert("A Down Action Occured"); 29 return true; 30 } 31 return false; 32 } 33 } 34


 

반응형