```java
/**
* bitmap转为base64
* @param bitmap
* @return
*/
public static String bitmapToBase64(Bitmap bitmap) {
String result = null;
ByteArrayOutputStream baos = null;
try {
if (bitmap != null) {
baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
baos.flush();
baos.close();
byte[] bitmapBytes = baos.toByteArray();
result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (baos != null) {
baos.flush();
baos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
/**
* base64转为bitmap
* @param base64Data
* @return
*/
public static Bitmap base64ToBitmap(String base64Data) {
byte[] bytes = Base64.decode(base64Data, Base64.DEFAULT);
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
```
- - -
```java
//ScrollViewåµå¥WebViewï¼ViewPagerçï¼å²çªè§£å³
webView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
scrollView.requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
scrollView.requestDisallowInterceptTouchEvent(false);
break;
}
return false;
}
});
```
- - -
```java
/**
* EditText设置ç¼è¾åä¸å¯ç¼è¾ï¼ç¸äºåæ¢
*â å¨xmlä¸è®¾ç½®å±æ§ focusable="false"ï¼
*â¡å¯ç¼è¾ä»£ç
*/
editText.setFocusableInTouchMode(true);
editText.setFocusable(true);
editText.requestFocus();
//ä¸å¯ç¼è¾ä»£ç ï¼
editText.setFocusable(false);
editText.setFocusableInTouchMode(false);
```
- - -
```java
/**
* 毫ç§å¼ï¼longï¼è½¬æå®æ¥ææ ¼å¼
*/
SimpleDateFormat simple = new SimpleDateFormat("yyyyå¹´MMæddæ¥ HH:mm");
Date date = new Date(Long.parseLong("æ¶é´å符串"));
String time = simple.format(date);
```
- - - - -
```java
/**
* è·åæ¬å°æ¶é´ï¼æ¾ç¤ºæå®æ ¼å¼
*/
SimpleDateFormat simple = new SimpleDateFormat("yyyyå¹´MMæddæ¥");
Date date = new Date(System.currentTimeMillis());
String currentTime = simple.format(date);
```
- - - - -
```xml
/**
* Android 5.0以ä¸çæ¬å»æ Button èªå¸¦é´å½±ææ
*/
// æ ¸å¿ä»£ç
style=â?android:attr/borderlessButtonStyleâ
```
- - - - -
```java
// Gson è§£æè¿åä¸ä¸ª List
String str="[{'id': '1','code': 'bj','name': 'å京','map': '39.90403, 116.40752599999996'}, {'id': '2','code': 'sz','name': 'æ·±å³','map': '22.543099, 114.05786799999998'}, {'id': '9','code': 'sh','name': '䏿µ·','map': '31.230393,121.473704'}, {'id': '10','code': 'gz','name': '广å·','map': '23.129163,113.26443500000005'}]";
Gson gson = new Gson();
List rs = new ArrayList();
Type type = new TypeToken>() {}.getType();
rs=gson.fromJson(str, new TypeToken>(){}.getType());
// Gson è§£æè¿åä¸ä¸ªmap
String jsonStr="{'1': {'id': '1','code': 'bj','name': 'å京','map': '39.90403, 116.40752599999996'},'2': {'id': '2','code': 'sz','name': 'æ·±å³','map': '22.543099, 114.05786799999998'},'9': {'id': '9','code': 'sh','name': '䏿µ·','map': '31.230393,121.473704'},'10': {'id': '10','code': 'gz','name': '广å·','map': '23.129163,113.26443500000005'}}";
Map citys = gson.fromJson(jsonStr, new TypeToken