DEV Tạo Pop-up screen

Thảo luận trong 'DEV - Khu Vực Dành Cho Lập Trình Viên' bắt đầu bởi Aric Lam, 10/9/12.

  1. Pop-up Screen cho phép pop up 1 cửa sổ thông tin đơn giản ngắn gọn như About, Info...


    Mã:
    /*
    * AboutScreen.java
    *
    * © Viet Hop Software, 2012
    * Confidential and proprietary.
    *
    * Developer: Aric
    * Email: sd@viethop.net
    */
     
    import net.rim.device.api.system.Characters;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.SeparatorField;
    import net.rim.device.api.ui.container.PopupScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    import net.rim.device.api.system.ApplicationDescriptor;
     
    /**
    * PopupScreen that displays information about the application
    */
     
     
    final class AboutScreen extends PopupScreen
    {
        /**
        * Constructor.
        */
        AboutScreen()
        {
            super(new VerticalFieldManager());
          super(new HorizontalFieldManager(NO_VERTICAL_SCROLL));
            ApplicationDescriptor appDesc = ApplicationDescriptor.currentApplicationDescriptor();
       
    BitmapField bitmap = new BitmapField(appDesc.getIcon(), FIELD_VCENTER);
    bitmap.setMargin(5, 5, 5, 5);
    add(bitmap);
     
            VerticalFieldManager vfm = new VerticalFieldManager();
     
            vfm.add(new LabelField(appDesc.getName() + " - Ver. " + appDesc.getVersion()));
     
            vfm.add(new SeparatorField());
            vfm.add(new LabelField("sd@viethop.net\nViet Hop Software © 2012"));
        }
     
     
        /**
        * Overrides the default.  Closes the popup screen when the Escape key is pressed.
        *
        * @see net.rim.device.api.ui.Screen#keyChar(char,int,int)
        */
        public boolean keyChar(char c, int status, int time)
        {
            if (c == Characters.ESCAPE)  // Đóng cửa sổ khi người dùng nhấn Escape.
            {
                close();
                return true;
            }
       
            return super.keyChar(c, status, time);
        }
    }
    
    9930.png
    Hình 1: Minh họa Pop-up Screen​
     
    Aric Lam

    Aric Lam
    Expand Collapse

    Go & Let's go

    Tham gia ngày:
    6/4/11
    Bài viết:
    4,710
    Đã được thích:
    2,921
    #1 Aric Lam, 10/9/12
    Last edited: 19/9/12

Chia sẻ trang này

PING