메뉴 항목 만들기 및 등록
ApplicationMenuItem 클래스를 확장하여 BlackBerry
Device Software 프로그램에서 표시할 메뉴 항목을 정의합니다.
- 필요한 클래스와 인터페이스를 가져옵니다.
import java.lang.IllegalStateException;
import net.rim.blackberry.api.menuitem.ApplicationMenuItem;
import net.rim.blackberry.api.menuitem.ApplicationMenuItemRepository;
- 메뉴 항목을 만들어 등록하려면 다음 작업을 수행합니다.
작업
|
단계
|
메뉴 항목 정의
|
- ApplicationMenuItem 클래스를 확장합니다.
public class SampleMenuItem extends ApplicationMenuItem { ... }
|
메뉴 항목이 메뉴에 배치되는 위치를 지정합니다.
|
- ApplicationMenuItem을 생성합니다. 생성자에서 숫자가 높을수록 메뉴 내의 메뉴 항목 위치가 내려갑니다.
SampleMenuItem()
{
super(0x350100);
}
|
메뉴 항목 텍스트를 지정합니다.
|
- toString()을 구현합니다.
public String toString()
{
return "My menu item";
}
|
메뉴 항목의 동작을 지정합니다.
|
- run()을 구현합니다.
public Object run(Object context)
{
// the menu's action here
return null;
}
|
메뉴 항목 등록
|
- ApplicationMenuItemRepository.addMenuItem()를 호출합니다.
ApplicationMenuItemRepository amir =
ApplicationMenuItemRepository.getInstance();
amir.addMenuItem(
ApplicationMenuItemRepository.MENUITEM_PHONE,
mySampleMenuItem);
|
코드 샘플: 메뉴 항목 만들기 및 등록
// Create menu item
int placement = 0x350100;
ApplicationMenuItem ami = new ApplicationMenuItem(placement)
{
public Object run(Object context)
{
// do something
return null;
}
public String toString()
{
return "My menu item";
}
};
// Register menu item to display when user views a contact
ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_ADDRESSCARD_VIEW, ami);
자세한 내용은 BlackBerry Java Development Environment용 API 참조서의 'Application Integration(프로그램 통합)' 카테고리 개요를 참조하십시오.
이 정보가 도움이 되었습니까? 의견을 보내 주십시오.