监听android控件焦点改变

  OnFocusChangeListenerTask buttonfocus=new OnFocusChangeListenerTask();
  
  task_button.setOnFocusChangeListener(buttonfocus);

 

private class OnFocusChangeListenerTask implements OnFocusChangeListener {
     public void onFocusChange(View v, boolean hasFocus) {// 表示操作的组件,而hasFocus表示是否获得焦点
         // TODO Auto-generated method stub
     // Log.i (TAG, "v.getId ="+v.getId()+" R.id.task_button="+R.id.task_button+" R.id.ratelimit_button="+R.id.ratelimit_button
      //  +" R.id.disk_button ="+R.id.disk_button+ " R.id.account_button="+R.id.account_button);
      if(hasFocus)
      {
       if(v.getId() == R.id.task_button)
       {
  
               
        //Log.v("task","==============task id===========" + v.getId());

      }

    }else

    {

     if(v.getId() == R.id.task_button)
       {
 
              
        //Log.v("task","==============task id===========" + v.getId());

      }

 

     }

展开阅读全文

没有更多推荐了,返回首页