私は wait( ); を使用するのが初めてです。特徴。私はそれが正しいと思っていましたが、実行されません。例を見て、どこで間違ったのかわかりません。誰か助けてくれませんか?前もって感謝します!
public class MainActivity
extends Activity
{
private ImageView splash;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
initialize();
}
private void initialize()
{
splash.setVisibility(View.VISIBLE);
try
{
wait(5000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
mainMenu();
}
private void mainMenu()
{
setContentView(R.layout.mainmenu);
}
ログキャット:
04-04 23:08:40.075: E/Trace(2555): error opening trace file: No such file or directory (2)
04-04 23:08:48.345: E/AndroidRuntime(2555): FATAL EXCEPTION: main
04-04 23:08:48.345: E/AndroidRuntime(2555): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.virginia.hotncolduva/edu.virginia.hotncolduva.MainActivity}: java.lang.NullPointerException
04-04 23:08:48.345: E/AndroidRuntime(2555): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-04 23:08:48.345: E/AndroidRuntime(2555): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-04 23:08:48.345: E/AndroidRuntime(2555): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-04 23:08:48.345: E/AndroidRuntime(2555): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-04 23:08:48.345: E/AndroidRuntime(2555): at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 23:08:48.345: E/AndroidRuntime(2555): at android.os.Looper.loop(Looper.java:137)
04-04 23:08:48.345: E/AndroidRuntime(2555): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-04 23:08:48.345: E/AndroidRuntime(2555): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 23:08:48.345: E/AndroidRuntime(2555): at java.lang.reflect.Method.invoke(Method.java:511)
04-04 23:08:48.345: E/AndroidRuntime(2555): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-04 23:08:48.345: E/AndroidRuntime(2555): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-04 23:08:48.345: E/AndroidRuntime(2555): at dalvik.system.NativeStart.main(Native Method)
04-04 23:08:48.345: E/AndroidRuntime(2555): Caused by: java.lang.NullPointerException
04-04 23:08:48.345: E/AndroidRuntime(2555): at edu.virginia.hotncolduva.MainActivity.initialize(MainActivity.java:24)
04-04 23:08:48.345: E/AndroidRuntime(2555): at edu.virginia.hotncolduva.MainActivity.onCreate(MainActivity.java:19)
04-04 23:08:48.345: E/AndroidRuntime(2555): at android.app.Activity.performCreate(Activity.java:5104)
04-04 23:08:48.345: E/AndroidRuntime(2555): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-04 23:08:48.345: E/AndroidRuntime(2555): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-04 23:08:48.345: E/AndroidRuntime(2555): ... 11 more
04-04 23:12:09.646: E/AndroidRuntime(2639): FATAL EXCEPTION: main
04-04 23:12:09.646: E/AndroidRuntime(2639): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.virginia.hotncolduva/edu.virginia.hotncolduva.MainActivity}: java.lang.NullPointerException
04-04 23:12:09.646: E/AndroidRuntime(2639): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-04 23:12:09.646: E/AndroidRuntime(2639): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-04 23:12:09.646: E/AndroidRuntime(2639): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-04 23:12:09.646: E/AndroidRuntime(2639): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-04 23:12:09.646: E/AndroidRuntime(2639): at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 23:12:09.646: E/AndroidRuntime(2639): at android.os.Looper.loop(Looper.java:137)
04-04 23:12:09.646: E/AndroidRuntime(2639): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-04 23:12:09.646: E/AndroidRuntime(2639): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 23:12:09.646: E/AndroidRuntime(2639): at java.lang.reflect.Method.invoke(Method.java:511)
04-04 23:12:09.646: E/AndroidRuntime(2639): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-04 23:12:09.646: E/AndroidRuntime(2639): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-04 23:12:09.646: E/AndroidRuntime(2639): at dalvik.system.NativeStart.main(Native Method)
04-04 23:12:09.646: E/AndroidRuntime(2639): Caused by: java.lang.NullPointerException
04-04 23:12:09.646: E/AndroidRuntime(2639): at edu.virginia.hotncolduva.MainActivity.initialize(MainActivity.java:24)
04-04 23:12:09.646: E/AndroidRuntime(2639): at edu.virginia.hotncolduva.MainActivity.onCreate(MainActivity.java:19)
04-04 23:12:09.646: E/AndroidRuntime(2639): at android.app.Activity.performCreate(Activity.java:5104)
04-04 23:12:09.646: E/AndroidRuntime(2639): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-04 23:12:09.646: E/AndroidRuntime(2639): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-04 23:12:09.646: E/AndroidRuntime(2639): ... 11 more
04-04 23:16:21.095: E/AndroidRuntime(2737): FATAL EXCEPTION: main
04-04 23:16:21.095: E/AndroidRuntime(2737): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.virginia.hotncolduva/edu.virginia.hotncolduva.MainActivity}: java.lang.NullPointerException
04-04 23:16:21.095: E/AndroidRuntime(2737): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-04 23:16:21.095: E/AndroidRuntime(2737): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-04 23:16:21.095: E/AndroidRuntime(2737): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-04 23:16:21.095: E/AndroidRuntime(2737): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-04 23:16:21.095: E/AndroidRuntime(2737): at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 23:16:21.095: E/AndroidRuntime(2737): at android.os.Looper.loop(Looper.java:137)
04-04 23:16:21.095: E/AndroidRuntime(2737): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-04 23:16:21.095: E/AndroidRuntime(2737): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 23:16:21.095: E/AndroidRuntime(2737): at java.lang.reflect.Method.invoke(Method.java:511)
04-04 23:16:21.095: E/AndroidRuntime(2737): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-04 23:16:21.095: E/AndroidRuntime(2737): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-04 23:16:21.095: E/AndroidRuntime(2737): at dalvik.system.NativeStart.main(Native Method)
04-04 23:16:21.095: E/AndroidRuntime(2737): Caused by: java.lang.NullPointerException
04-04 23:16:21.095: E/AndroidRuntime(2737): at edu.virginia.hotncolduva.MainActivity.initialize(MainActivity.java:27)
04-04 23:16:21.095: E/AndroidRuntime(2737): at edu.virginia.hotncolduva.MainActivity.onCreate(MainActivity.java:20)
04-04 23:16:21.095: E/AndroidRuntime(2737): at android.app.Activity.performCreate(Activity.java:5104)
04-04 23:16:21.095: E/AndroidRuntime(2737): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-04 23:16:21.095: E/AndroidRuntime(2737): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-04 23:16:21.095: E/AndroidRuntime(2737): ... 11 more
04-04 23:20:05.727: E/AndroidRuntime(2833): FATAL EXCEPTION: main
04-04 23:20:05.727: E/AndroidRuntime(2833): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.virginia.hotncolduva/edu.virginia.hotncolduva.MainActivity}: java.lang.NullPointerException
04-04 23:20:05.727: E/AndroidRuntime(2833): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-04 23:20:05.727: E/AndroidRuntime(2833): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-04 23:20:05.727: E/AndroidRuntime(2833): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-04 23:20:05.727: E/AndroidRuntime(2833): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-04 23:20:05.727: E/AndroidRuntime(2833): at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 23:20:05.727: E/AndroidRuntime(2833): at android.os.Looper.loop(Looper.java:137)
04-04 23:20:05.727: E/AndroidRuntime(2833): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-04 23:20:05.727: E/AndroidRuntime(2833): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 23:20:05.727: E/AndroidRuntime(2833): at java.lang.reflect.Method.invoke(Method.java:511)
04-04 23:20:05.727: E/AndroidRuntime(2833): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-04 23:20:05.727: E/AndroidRuntime(2833): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-04 23:20:05.727: E/AndroidRuntime(2833): at dalvik.system.NativeStart.main(Native Method)
04-04 23:20:05.727: E/AndroidRuntime(2833): Caused by: java.lang.NullPointerException
04-04 23:20:05.727: E/AndroidRuntime(2833): at edu.virginia.hotncolduva.MainActivity.initialize(MainActivity.java:27)
04-04 23:20:05.727: E/AndroidRuntime(2833): at edu.virginia.hotncolduva.MainActivity.onCreate(MainActivity.java:20)
04-04 23:20:05.727: E/AndroidRuntime(2833): at android.app.Activity.performCreate(Activity.java:5104)
04-04 23:20:05.727: E/AndroidRuntime(2833): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-04 23:20:05.727: E/AndroidRuntime(2833): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-04 23:20:05.727: E/AndroidRuntime(2833): ... 11 more