4.9 黑名单数据库的界面展示

调用dao层中查询数据库中数据的方法,将得到的数据装进集合中,显示在listView中

 

 

 

 

public   class   CallSmsSafeActivity   extends   Activity {

       private   String   TAG =   "CallSmsSafeActivity" ;
       private   ListView   lv_callsms_safe ;
       private   BlackNumberDao   dao ;
       private   BlackNumberBean   blackNumberBean ;
       private   List<BlackNumberBean>   numberList   ;
       private   TextView    tv_number ;
       private   TextView    tv_mode ;
       private   ImageView iv_delete;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
            setContentView(R.layout. activity_callsms_safe);
            
             dao= new BlackNumberDao( this);
             numberList= dao.getNumberInfo();
            
            
             lv_callsms_safe=(ListView) findViewById(R.id.lv_callsms_safe );
             lv_callsms_safe.setAdapter( new MyAdapter());
            
            
      }
      
      
       /**
       * 创建适配器
       */
       public   class   MyAdapter    extends   BaseAdapter{

            
               @Override
               public   int   getCount() {
                  
                     return   numberList .size();
            }
            
            
               @Override
               public   View getView( int   position, View convertView, ViewGroup parent) {
                   View view = View. inflate(getApplicationContext(), R.layout. list_callsms_item , null   );
                     tv_number =(TextView) view.findViewById(R.id. tv_number   );
                     tv_mode =(TextView) view.findViewById(R.id.   tv_mode );
                     iv_delete =(ImageView) view.findViewById(R.id. iv_delete   );
                  
                     blackNumberBean   =   numberList .get(position);
                     tv_number .setText(   "号码:" + blackNumberBean   .getNumber());
                   String mode=   blackNumberBean .getMode();
                     if (   "1" .equals(mode)){
                           tv_mode .setText(   "电话拦截" );
                   }   else   if (   "2" .equals(mode)){
                           tv_mode .setText(   "短信拦截" );
                   }   else   if (   "3" .equals(mode)){
                           tv_mode .setText(   "全部拦截" );
                   }
                  
                     //给小垃圾桶图标设置删除事件
                     new   Thread(){
                        
                           public   void   run() {
                              
                                 iv_delete .setOnClickListener(   new   OnClickListener() {
                                    
                                    

                                       @Override
                                       public   void   onClick(View v) {
                                          
                                             dao .delete(   blackNumberBean .getNumber());
                                          
                                          Log. i( TAG   ,   "删除....."   );
                                    }
                              });
                         };
                        
                        
                   }.start();
                  
                  
                  
                     return   view;
            }

               @Override
               public   Object getItem(   int   position) {
                  
                     return   null ;
            }

               @Override
               public   long   getItemId(   int   position) {
                  
                     return   0;
            }

            
            
      }
      
      
      
}

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值