私はAndroidを初めて使用します。チュートリアルに従って、PHPとMySQLを使用してログイン画面を作成しました...数日前に機能しました。アプリを実行しようとすると、強制終了エラーとJava.lang.NullPointerExceptionが発生します。 。それは、あるはずのない何かがnullであることを意味すると思いますか?誰かが私を助けてくれませんか?
これは私のLogCatです:
12-03 11:48:06.089: D/AndroidRuntime(13538): Shutting down VM
12-03 11:48:06.099: W/dalvikvm(13538): threadid=1: thread exiting with uncaught exception (group=0x2aac8560)
12-03 11:48:06.099: E/AndroidRuntime(13538): FATAL EXCEPTION: main
12-03 11:48:06.099: E/AndroidRuntime(13538): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.groupone.the.health.effect/com.groupone.the.health.effect.AndroidDashboardDesignActivity}: java.lang.NullPointerException
12-03 11:48:06.099: E/AndroidRuntime(13538): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
12-03 11:48:06.099: E/AndroidRuntime(13538): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
12-03 11:48:06.099: E/AndroidRuntime(13538): at android.app.ActivityThread.access$1500(ActivityThread.java:121)
12-03 11:48:06.099: E/AndroidRuntime(13538): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
12-03 11:48:06.099: E/AndroidRuntime(13538): at android.os.Handler.dispatchMessage(Handler.java:99)
12-03 11:48:06.099: E/AndroidRuntime(13538): at android.os.Looper.loop(Looper.java:123)
12-03 11:48:06.099: E/AndroidRuntime(13538): at android.app.ActivityThread.main(ActivityThread.java:3701)
12-03 11:48:06.099: E/AndroidRuntime(13538): at java.lang.reflect.Method.invokeNative(Native Method)
12-03 11:48:06.099: E/AndroidRuntime(13538): at java.lang.reflect.Method.invoke(Method.java:507)
12-03 11:48:06.099: E/AndroidRuntime(13538): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
12-03 11:48:06.099: E/AndroidRuntime(13538): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
12-03 11:48:06.099: E/AndroidRuntime(13538): at dalvik.system.NativeStart.main(Native Method)
12-03 11:48:06.099: E/AndroidRuntime(13538): Caused by: java.lang.NullPointerException
12-03 11:48:06.099: E/AndroidRuntime(13538): at com.groupone.the.health.effect.AndroidDashboardDesignActivity.onCreate(AndroidDashboardDesignActivity.java:92)
12-03 11:48:06.099: E/AndroidRuntime(13538): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-03 11:48:06.099: E/AndroidRuntime(13538): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
12-03 11:48:06.099: E/AndroidRuntime(13538): ... 11 more
これが私の.AndroidDashboardDesignActivityです。
package com.groupone.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class AndroidDashboardDesignActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dashboard_layout);
/**
* Creating all buttons instances
* */
// Dash board News feed button
Button btn_newsfeed = (Button) findViewById(R.id.btn_news_feed);
// Dash board Friends button
Button btn_friends = (Button) findViewById(R.id.btn_friends);
// Dash board Messages button
Button btn_messages = (Button) findViewById(R.id.btn_messages);
// Dash board Places button
Button btn_places = (Button) findViewById(R.id.btn_places);
// Dash board Events button
Button btn_events = (Button) findViewById(R.id.btn_events);
// Dash board Photos button
Button btn_photos = (Button) findViewById(R.id.btn_photos);
/**
* Handling all button click events
* */
// Listening to News Feed button click
btn_newsfeed.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Launching News Feed Screen
Intent i = new Intent(getApplicationContext(), NewsFeedActivity.class);
startActivity(i);
}
});
// Listening Friends button click
btn_friends.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Launching News Feed Screen
Intent i = new Intent(getApplicationContext(), AndroidFacebookConnectActivity.class);
startActivity(i);
}
});
// Listening Messages button click
btn_messages.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Launching News Feed Screen
Intent i = new Intent(getApplicationContext(), MessagesActivity.class);
startActivity(i);
}
});
// Listening to Places button click
btn_places.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Launching News Feed Screen
Intent i = new Intent(getApplicationContext(), MessagesActivity.class);
startActivity(i);
}
});
// Listening to Events button click
btn_events.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Launching News Feed Screen
Intent i = new Intent(getApplicationContext(), MessagesActivity.class);
startActivity(i);
}
});
// Listening to Photos button click
btn_photos.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Launching News Feed Screen
Intent i = new Intent(getApplicationContext(), PhotosActivity.class);
startActivity(i);
}
});
}
}
これが私のレイアウトです:
!-- Your package folder -->
<com.groupone.the.health.effect.DashboardLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#3b3b3b" >
<!-- News Feed Button -->
<Button
android:id="@+id/btn_news_feed"
style="@style/DashboardButton"
android:drawableTop="@drawable/healthbook"
android:text="Activities" />
<Button
android:id="@+id/btn_messages"
style="@style/DashboardButton"
android:drawableTop="@drawable/mental"
android:text="Mental Input" />
<!-- Events Button -->
<Button
android:id="@+id/btn_events"
style="@style/DashboardButton"
android:drawableTop="@drawable/graph"
android:text="Results" />
<!-- Photos Button -->
<!-- Friends Button -->
<Button
android:id="@+id/btn_friends"
style="@style/DashboardButton"
android:drawableTop="@drawable/btn_facebook"
android:text="Facebook" />
<!-- Messages Button -->
<!-- Places Button -->
<Button
android:id="@+id/btn_places"
style="@style/DashboardButton"
android:drawableTop="@drawable/twitter_logo"
android:text="Health Tweets" />
<Button
android:id="@+id/btnLogout"
style="@style/DashboardButton"
android:drawableTop="@drawable/logout"
android:text="Log Out"/>
</com.groupone.the.health.effect.DashboardLayout>