icon上添加数字提醒

使用viewbadger包:

 1 package com.jingle.vierbagerstudy;
 2 
 3 import android.app.Activity;
 4 import android.os.Bundle;
 5 import android.widget.ImageView;
 6 
 7 import com.readystatesoftware.viewbadger.BadgeView;
 8 
 9 public class MainActivity extends Activity {
10 
11     @Override
12     protected void onCreate(Bundle savedInstanceState) {
13         super.onCreate(savedInstanceState);
14         setContentView(R.layout.activity_main);
15 
16         initImg();
17     }
18 
19     private void initImg() {
20         ImageView img = (ImageView) findViewById(R.id.img);
21         img.setImageResource(R.drawable.ic_launcher);
22         
23         //使用image,context初始化badgeView
24         BadgeView badge = new BadgeView(this, img);
25         badge.setText("ok");//设置显示的数字
26         badge.show();//显示badge
      //badge.hide()//隐藏badge
27 } 31 }

 

posted @ 2015-03-24 11:18  鲸歌  阅读(313)  评论(0编辑  收藏  举报