加入android:largeHeap="true"
可參考文章
http://hilary3113.iteye.com/blog/1766856
如果你在設定背景圖片時 發現出現記憶體不足的問題(Out of Memory 異常) 可以考慮使用以下的Code
// Minimize 類別
public class Minimize {
/**
* 以最省記憶體的方式來存取圖片
*
* @param context
* @param resId
* @return
*/
private static Bitmap readBitMap(Context context, int resId) {
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inPreferredConfig = Bitmap.Config.RGB_565;
opt.inPurgeable = true;
opt.inInputShareable = true;
// 獲取圖片資源
InputStream is = context.getResources().openRawResource(resId);
return BitmapFactory.decodeStream(is, null, opt);
}
//將redId採取Bitmap 再轉成BitmapDrawable 就可以setBackground()了
public static BitmapDrawable getBitmapDrawable(Context context,int redId){
Bitmap bm = readBitMap(context, redId);
BitmapDrawable bd = new BitmapDrawable(context.getResources(), bm);//轉換成Drawable
return bd;
}
}
//之後設定背景 RelativeLayout background = (RelativeLayout) findViewById(R.id.map); background.setBackground(Minimize.getBitmapDrawable(this, R.drawable.map_relaxbg));
//以下方法並不適用 他會先出現標題之後再轉成無標題的怪異行徑
//若要採用 請記得放至setContentView()的前面
private void setWindows() {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);//設定全螢幕
requestWindowFeature(Window.FEATURE_NO_TITLE);//設定無標題
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//設定橫向
}
CREATE TABLE parent(a PRIMARY KEY, b UNIQUE, c, d, e, f); CREATE UNIQUE INDEX i1 ON parent(c, d); CREATE INDEX i2 ON parent(e); CREATE UNIQUE INDEX i3 ON parent(f COLLATE nocase); CREATE TABLE child1(f, g REFERENCES parent(a)); -- Ok CREATE TABLE child2(h, i REFERENCES parent(b)); -- Ok CREATE TABLE child3(j, k, FOREIGN KEY(j, k) REFERENCES parent(c, d)); -- Ok CREATE TABLE child4(l, m REFERENCES parent(e)); -- Error! CREATE TABLE child5(n, o REFERENCES parent(f)); -- Error! CREATE TABLE child6(p, q, FOREIGN KEY(p, q) REFERENCES parent(b, c)); -- Error! CREATE TABLE child7(r REFERENCES parent(c)); -- Error!