许多这样的小tips, 记下来, 下次用到好找.
很简单
- Android 如何从底往上添加listview的items
android:stackFromBottom=”true”
- 打开一个页面时不自动弹出键盘
activity设置为
android:focusableInTouchMode=”true”
edittext去掉requestFocusable
- ListView,数据更新后自动scroll到底部
android:transcriptMode=”alwaysScroll”
- Action Bar 的item 显示为图标
android:showAsAction=”always”
- 由文件名生成Bitmap
File imgFile = new File(fileName);
Bitmap bitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
- int与byte[]的互相转换
public static int bytesToInt(byte[] b) {
int value = 0;
for (int i = 0; i
int shift = i * 8;
value += (b[i] & 0x000000FF)
}
return value;
}
public static byte[] intToBytes(int a)
{
byte[] ret = new byte[4];
ret[0] = (byte) (a & 0xFF);
ret[1] = (byte) ((a >> 8) & 0xFF);
ret[2] = (byte) ((a >> 16) & 0xFF);
ret[3] = (byte) ((a >> 24) & 0xFF);
return ret;
}