//EditText左右抖动
private EditText ed_number;
et_number = (EditText) findViewById(R.id.et_number);
Animation shake = <span style="color:#ff0000;">AnimationUtils.loadAnimation</span>(this, R.anim.shake);
et_number.startAnimation(shake);
//EditText内容变化监听
//给输入框添加内容变化的监听器
et_number.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//查询电话号码的归属地
queryAddress(null);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
R.anim.shake.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXDelta="0"
android:interpolator="@anim/cycle_7"
android:toXDelta="10" />
手机震动
private Vibrator vibrator;
vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
vibrator.vibrate(1000);//震动1s
long[] pattern = new long[]{300,500,700,900};
//pattern 震动变化的时间段
//repeat 从pattern的哪个数组下标开始震动
vibrator.vibrate(pattern, 0);//震动300ms停500ms震动700ms停900ms