Android 为什么';我的吐司不管用吗?
基本上,我无法让我的toast出现在我的应用程序的屏幕上,我已经将toast代码复制到另一个应用程序中,代码运行良好,只是出于某种原因,我似乎无法让它在这个应用程序中运行。我已经将我的应用程序剥离回初始屏幕,它除了在onCreate方法中调用toast之外什么都不做,但仍然什么都没有。我已经尝试了我能想到的一切。有人能告诉我有什么问题吗?非常感谢您的帮助Android 为什么';我的吐司不管用吗?,android,toast,Android,Toast,基本上,我无法让我的toast出现在我的应用程序的屏幕上,我已经将toast代码复制到另一个应用程序中,代码运行良好,只是出于某种原因,我似乎无法让它在这个应用程序中运行。我已经将我的应用程序剥离回初始屏幕,它除了在onCreate方法中调用toast之外什么都不做,但仍然什么都没有。我已经尝试了我能想到的一切。有人能告诉我有什么问题吗?非常感谢您的帮助 public class Splash extends Activity{ @Override public void on
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
下面给出了清单,以防对任何人都有用,额外的活动是从主菜单启动的,但我将启动主菜单的意图从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>
用
Toast t1 = new Toast(context);
t1.makeText(....);
t1.show()
或使用
Toast.makeText(...).show();
坏了的烤面包机?你能在
onCreate
中烤面包吗,因为它还不在应用程序/片段生命周期的可见阶段?是的,你可以用tronic,因为我在另一个应用程序的onCreate中调用了一个烤面包机,它工作得很好,我把它放在那里是为了让它更简单,它不工作在点击方法或任何其他地方,我把它在这个应用程序,嗯。。。有趣的对我来说工作。。。与您使用的语法完全相同。这看起来像是一个Eclipse问题。尝试一个项目->清理只是尝试了一下,什么都没有,是否清单或xml布局文件可能会阻止toast?尝试了您描述的两种方法,什么都没有,我尝试了所有方法