项目经验积累

1      时间格式输出

        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd_HHmmss");
        Date curDate = new Date(System.currentTimeMillis());// 获取当前时间
        String filename_text = formatter.format(curDate);

2   toast

   if(errorToast == null){
   errorToast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT); 
   errorToast.show();
   }

 errorToast .cancel  //去掉

3  tween动画

    旋转

   /* 创建磁轮Rotate动画 */
  mAnimationRotate = new RotateAnimation(0.0f, +360.0f,
    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
    0.5f);
  /* 设置动画的时间 */
  mAnimationRotate.setDuration(2500);
  mAnimationRotate.setInterpolator(new LinearInterpolator());   //匀速  (之前为这个参数纠结很久)
  mAnimationRotate.setRepeatCount(-1);   // 重复
  // mAnimationRotate.setFillAfter(true);  // 停止时 停留在最后一帧

  wheel_left.setAnimation(mAnimationRotate);  //  imageview

  ------

  wheel_left.clearAnimation();  //  停止

View和输入法的交互

onFocusChanged()
失去焦点调用用imm.focusOut(), 得到焦点调用imm.focusIn()

onWindowFocusChanged
失去焦点调用用imm.focusOut(), 得到焦点调用imm.focusIn()

TextView和输入法的交互
setInputType()
改变输入法类型后, 会重启输入法imm.restartInput()

onEditorAction()     //  按 完成键后的响应
收到输入完成事件,隐藏输入法界面imm.hideSoftInputFromWindow()
onKeyUp()
收到KEYCODE_DPAD_CENTER按键事件, 显示输入法界面imm.showSoftInput,这个事件鼠标左键点击,都是输入框获取焦点。
收到KeyEvent.KEYCODE_ENTER按键事件,状态是输入完成,关闭输入法界面imm.hideSoftInputFromWindow()

onTouchEvent()
触屏事件, 输入框获取焦点, 显示输入法界面imm.showSoftInput

isInputMethodTarget()
调用imm.isActive(), 用来判断此控件是否启用输入法

onTextContextMenuItem()
如果用户选择了“切换输入法”(ID_SWITCH_INPUT_METHOD),显示输入法菜单imm.showInputMethodPicker

setKeyListener()
每次调用都重启输入法imm.restartInput()

setText()
输入框内容改变, 重启输入法imm.restartInput()

 

5 Notification

 public void showsrstatus() {

  SrNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  Notification srnotification = new Notification();
  srnotification.icon = R.drawable.ic_launcher_xxxx;
  srnotification.tickerText = "xxxxx";
  srnotification.when = System.currentTimeMillis();
  srnotification.flags = srnotification.FLAG_ONGOING_EVENT;
  Intent intent = new Intent(xxxx.this, xxxx.class);
  PendingIntent pi = PendingIntent.getActivity(xxxx.this, 0,intent, 0); // 消息触发后调用
  srnotification.setLatestEventInfo(xxxxx.this, " "
    + getResources().getString(R.string.app_name), getResources()
    .getString(R.string.your_message), pi);
  SrNotificationManager.notify(SR_NOTIFI_ID, srnotification);
 }

 public void closesrstatus() {
  SrNotificationManager.cancel(SR_NOTIFI_ID);
 }

 

6  创建文件夹

  File sampleDir = new File(PATH);

        if(!sampleDir.exists()){
         sampleDir.mkdir();
        }
  

 

 

 

 

 



 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值