BB 透明的 PopupScreen

本文介绍了一个 BlackBerry 平台上定制化的弹窗组件实现方式。该组件使用 FlowFieldManager 布局,并通过 Graphics API 绘制背景及文本内容。文章展示了如何设置弹窗的位置、大小,并使用自定义颜色绘制透明背景。

转自: http://doll.iteye.com/blog/588502

 

  1. import net.rim.device.api.ui.Color;   
  2. import net.rim.device.api.ui.Graphics;   
  3. import net.rim.device.api.ui.Manager;   
  4. import net.rim.device.api.ui.container.FlowFieldManager;   
  5. import net.rim.device.api.ui.container.PopupScreen;   
  6.   
  7. public class PopupView extends PopupScreen {   
  8.   
  9.     public PopupView() {   
  10.         super(new FlowFieldManager(Manager.FIELD_HCENTER));   
  11.     }   
  12.   
  13.     protected void paint(Graphics g) {   
  14.         g.setColor(Color.RED);   
  15.         g.drawText("Just do it"00);   
  16.     }   
  17.   
  18.     public void _drawAlpha(int _x, int _y, int _width, int _height, int _color,   
  19.             Graphics g) {   
  20.         int _array[] = new int[_width * _height];   
  21.         for (int i = 0; i < _array.length; i++) {   
  22.             _array[i] = _color;   
  23.         }   
  24.         g.drawARGB(_array, 0, _width, _x, _y, _width, _height);   
  25.   
  26.     }   
  27.   
  28.     protected void paintBackground(Graphics graphics) {   
  29.         // super.paintBackground(graphics);   
  30.         _drawAlpha(00this.getWidth(), this.getHeight(), 0X66223311,   
  31.                 graphics);   
  32.     }   
  33.   
  34.     protected void sublayout(int width, int height) {   
  35.         // super.sublayout(width, height);   
  36.         this.setPosition(012);   
  37.         this.setExtent(13030);   
  38.     }   
  39. }  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值