今天竟然捣鼓出一小效果隐藏editView中的部分内容,这个主要利用了editView背景色和字体一个颜色这样就相当于以藏了又是一招欺骗,哎看来欺骗哪里都好用
EditText tx =(EditText)findViewById(R.id.txt);
Spannable sText = (Spannable) tx.getText();
sText.setSpan(new BackgroundColorSpan(0xFFFFFF00), 11,15, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
sText.setSpan(new BackgroundColorSpan(Color.TRANSPARENT), 5,10, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
sText.setSpan(new ForegroundColorSpan(Color.WHITE), 1,3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
sText.setSpan(new ForegroundColorSpan(Color.TRANSPARENT),16,17,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
2
TextView tv = (TextView) findViewById(R.id.cctvex);
tv.setText("Please visit my website, http://wang_peng1.iteye.com or email me at 3323297@qq.com.");
Linkify.addLinks(tv, Linkify.ALL);
intent-filters填写
- android.net.wifi.WIFI_STATE_CHANGED
- action android:name="android.net.wifi.STATE_CHANGE
- android.net.wifi.supplicant.CONNECTION_CHANGE
权限
uses-permission android:name="android.permission.ACCESS_WIFI_STATE"
final String action = intent.getAction(); if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { NetworkInfo info = (NetworkInfo)intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); if (info.getState().equals(NetworkInfo.State.CONNECTED)) { //do whatever you want when wifi is active and connected to a hotspot } }
还有这句如果需要
if (action.equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION))
public class HorizontalReversePinchDetector {
public boolean onTouchEvent(MotionEvent e) {
int pointerCount = e.getPointerCount();
if(pointerCount != 2) {
Log.d(GESTURE, "not pinching - exactly 2 fingers are needed but have " + pointerCount);
clearPinch();
return false;
}
int firstIndex = e.getX(0) < e.getX(1) ? 0: 1;
int secondIndex = e.getX(0) < e.getX(1) ? 1: 0;
Finger currentLeftFinger = new Finger(e.getX(firstIndex), e.getY(firstIndex));
Finger currentRightFinger = new Finger(e.getX(secondIndex), e.getY(secondIndex));
float yDifference = Math.abs(currentLeftFinger.getY() - currentRightFinger.getY());
if(yDifference > 80) {
Log.d(GESTURE, "not pinching - fingers too vertically-oriented");
clearPinch();
return false;
}
if(initialLeftFinger == null) {
initialLeftFinger = currentLeftFinger;
initialRightFinger = currentRightFinger;
Log.d(GESTURE, "not pinching, but might be starting a pinch...");
return false;
}
float leftFingerDistance = initialLeftFinger.getX() - currentLeftFinger.getX();
float rightFingerDistance = currentRightFinger.getX() - initialRightFinger.getX();
float xDistanceBetweenFingers = Math.abs(currentLeftFinger.getX() - currentRightFinger.getX());
if(xDistanceBetweenFingers < minimumDistanceBetweenFingers) {
Log.d(GESTURE, "pinching, but fingers are not far enough apart...");
return true;
}
if(leftFingerDistance < minimumDistanceForEachFinger) {
Log.d(GESTURE, "pinching, but left finger has not moved enough...");
return true;
}
if(rightFingerDistance < minimumDistanceForEachFinger) {
Log.d(GESTURE, "pinching, but right finger has not moved enough...");
return true;
}
pinchCompleted();
return true;
}
private void pinchCompleted() {
Log.d(GESTURE, "pinch completed");
if(pinchListener != null) pinchListener.onPinch();
clearPinch();
}
public static interface OnPinchListener {
void onPinch();
}
private void clearPinch() {
initialLeftFinger = null;
initialRightFinger = null;
}
public void setPinchListener(OnPinchListener pinchListener) {
this.pinchListener = pinchListener;
}
private static class Finger {
private Finger(float x, float y) {
this.x = x;
this.y = y;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
private float x;
private float y;
}
private Finger initialLeftFinger;
private Finger initialRightFinger;
private OnPinchListener pinchListener;
private static final float minimumDistanceForEachFinger = 30;
private static final float minimumDistanceBetweenFingers = 50;
}