2013-03-27 94 views
0

基本上,我不能讓我的烤麪包在我的應用程序中出現在屏幕上,我已經將吐司代碼複製到不同的應用程序中,並且代碼正常工作,只是出於某種原因,我似乎無法使其工作在這一個。我已經將應用程序剝離回只是在onCreate方法中調用toast但什麼也不做的閃屏。我嘗試了所有我能想到的。有人可以告訴我它有什麼問題嗎?任何幫助是極大的讚賞。爲什麼我的烤麪包不起作用?

public class Splash extends Activity{ 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.splash_layout); 
     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

     Toast t1 = Toast.makeText(this, "hello world", Toast.LENGTH_LONG); 
     t1.show(); 

    }//end onCreate  
} // end splash 

清單中的情況下,下面給出的是對人有益的課外活動從主菜單啓動,但香港專業教育學院切斷啓動主菜單出來飛濺胡亞蓉的嘗試,並使其更簡單的意圖要弄清楚什麼是錯

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.bluetoothdms" 
    android:versionCode="1" 
     android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="11" 
    android:targetSdkVersion="17" /> 

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" 
    android:largeHeap="true"> 
    <activity 
     android:name="com.example.bluetoothdms.Splash" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name="com.example.bluetoothdms.MainMenu" 
     android:label="@string/app_name" > 
    </activity> 
    <activity 
     android:name="com.example.bluetoothdms.Bluetooth_Content" 
     android:label="@string/app_name" > 
    </activity> 
    <activity 
     android:name="com.example.bluetoothdms.DMS_Content" 
     android:label="@string/app_name" > 
    </activity> 
    <activity 
     android:name="com.example.bluetoothdms.FAQ" 
     android:label="@string/app_name" > 
    </activity> 
    <activity 
     android:name="com.example.bluetoothdms.File_Opener"> 
    </activity> 
</application> 

+10

破碎的烤麪包機? – 2013-03-27 13:57:08

+0

你可以在'onCreate'內做一個敬酒,因爲它還沒有在app/fragment生命週期的可見階段? – TronicZomB 2013-03-27 14:00:38

+1

是的,你可以... – 2013-03-27 14:02:29

回答

0

實例化Toast

Toast t1 = new Toast(context); 
t1.makeText(....); 
t1.show() 

或使用

Toast.makeText(...).show(); 
+0

嘗試過你已經描述過的兩種方式,沒有任何事情,我嘗試了一切 – user2052283 2013-03-27 14:07:36