2016-05-09 62 views
-2

當創建一個android應用程序介紹時,會出現內存滯後錯誤並停止應用程序。應用程序介紹錯誤java.lang.OutOfMemoryError

public class SampleSlide extends Fragment { 

    private static final String ARG_LAYOUT_RES_ID = "layoutResId"; 

    public static SampleSlide newInstance(int layoutResId) { 
     SampleSlide sampleSlide = new SampleSlide(); 
     Bundle args = new Bundle(); 
     args.putInt(ARG_LAYOUT_RES_ID, layoutResId); 
     sampleSlide.setArguments(args); 
     return sampleSlide; 
    } 

    private int layoutResId; 

    public SampleSlide() {} 

    @Override 
    public void onCreate(@Nullable Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     if(getArguments() != null && getArguments().containsKey(ARG_LAYOUT_RES_ID)) 
      layoutResId = getArguments().getInt(ARG_LAYOUT_RES_ID); 
    } 

    @Nullable 
    @Override 
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 
     return inflater.inflate(layoutResId, container, false); 
    } 

} 
+1

檢查這個裁判:HTTP://stackoverflow.com/questions/1393486/error-java-lang-outofmemoryerror-gc-overhead-limit-exceeded RQ = 1 –

+0

添加完整的logcat –

回答

0

如果您不必使用該代碼。只需在manifest.xml文件中定義的活動中定義以下事情即可解決您的問題。

<application 
    .... 
     android:largeHeap="true">