首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

状态栏应用prograssBar

2012-08-24 
状态栏使用prograssBarprivate static final int PROGRESS 0x1 ??? private static final int MAX_PROG

状态栏使用prograssBar

private static final int PROGRESS = 0x1;
??? private static final int MAX_PROGRESS = 100;
?
??? private int mProgressStatus = 10;
?
??? private Handler mHandler = new Handler();

??? @Override
??? public void onCreate(Bundle savedInstanceState) {
??????? super.onCreate(savedInstanceState);
??????? setContentView(R.layout.twolayout);
???????
??????? NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

??????? int icon = R.drawable.icon; //通知图标

??????? CharSequence tickerText = "Hello"; //状态栏显示的通知文本提示

??????? long when = System.currentTimeMillis(); //通知产生的时间,会在通知信息里显示

??????? //用上面的属性初始化Nofification

??????? Notification notification = new Notification(icon,tickerText,when);
???????
???????
???????
??????? final RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_layout);
??????? contentView.setProgressBar(R.id.progress_bar, MAX_PROGRESS, mProgressStatus, false);
??????
??????? notification.contentView = contentView;
?????
?
??????? // Start file upload in a background thread
??????? new Thread(new Runnable() {
??????????? public void run() {
??????????????? while (mProgressStatus < MAX_PROGRESS) {
??????????????????? mProgressStatus += mProgressStatus;
?
??????????????????? // Update the progress bar
??????????????????? mHandler.post(new Runnable() {
??????????????????????? public void run() {
??????????????????????????? contentView.setProgressBar(R.id.progress_bar, MAX_PROGRESS, mProgressStatus, false);
??????????????????????? }
??????????????????? });
??????????????? }
??????????? }
??????? }).start();
???????
???????
??????? Intent notificationIntent = new Intent(this,TestTwoDScrollView.class);

??????? PendingIntent contentIntent = PendingIntent.getActivity(this,0,notificationIntent,0);

??????? notification.contentIntent = contentIntent;

??????? manager.notify(1, notification);

热点排行