2013-10-16 49 views
-1

嗨,大家好,我想中的新飛濺類android開發小錯誤

添加啓動映像,但即時得到錯誤: splash cannot be resolved or is not a field

圖像已經存在的繪製,華電國際文件夾下情況下,PNG擴展

我的計劃是

package com.sc.uploader; 
import android.app.Activity; 
import android.os.Bundle; 

public class Splash extends Activity { 

@Override 
protected void onCreate(Bundle IloveU) { 
    // TODO Auto-generated method stub 
    super.onCreate(IloveU); 
    setContentView(R.layout.splash); 
} 



} 

我覺得一切都很好,但我不實LY知道爲什麼林遍地

收到此錯誤感謝您的幫助,我將非常感激

+0

神的方式告訴你,閃屏是邪惡的。 http://cyrilmottier.com/2012/05/03/splash-screens-are-evil-dont-use-them/ – Simon

回答

0

RES /佈局/ splash.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:background="@drawable/YOUR_IMAGE_WIHOUT_EXTENSION" 
    > 
</LinearLayout> 

這是你失去了什麼。原因是,setContentView(R.layout.splash)正在佈局文件夾中尋找佈局。對於你把圖像作爲開機畫面,這種方法,你需要把你的圖像文件轉換成drawable文件夾

+0

多數民衆贊成在驚人的。 – Scatteril

1

圖像已經存在的繪製,華電國際文件夾中的小寫字母,png格式的擴展

聽起來像splashdrawablesetContentView()需要layout這將是您的layout文件夾中的一個xml文件,該文件夾可能包含您要顯示的Image。該應用正在查找resources中的layout文件,其ID與splash.xml匹配,顯然它找不到該文件。

+0

非常感謝你 – Scatteril

0

setContentView()接受佈局的應用方法,這樣你就可以使用您的開機畫面定義下一個佈局splash.xml並將其保存在res/layout/splash.xml文件夾:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/splash" /> 
+0

謝謝你兄弟。 – Scatteril