そのエラーがあり、何が問題なのか理解できません。私はAndroid開発の初心者なので、ばかげたことをしたかもしれませんが、見つけられません...
ここに私の活動があります:
package pjl.appli;
import android.app.Activity;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
public class SoundGenActivity extends Activity {
/** Called when the activity is first created. */
RadioGroup radioGroup = new RadioGroup(this);
RadioButton fm = new RadioButton(this);
RadioButton granulaire = new RadioButton(this);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// On ajoute les boutons au RadioGroup
radioGroup.addView(fm, 0);
radioGroup.addView(granulaire, 1);
}
}
ここに私のmain.xmlがあります:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal" >
<RadioGroup
android:id="@+id/radioSyntheseSonore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/fm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fm"
android:checked="true" />
<RadioButton
android:id="@+id/granulaire"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/granulaire" />
</RadioGroup>
</LinearLayout>
そして、ここに私のlogcatがあります:
06-01 09:09:07.398: D/AndroidRuntime(800): Shutting down VM
06-01 09:09:07.398: W/dalvikvm(800): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
06-01 09:09:07.419: I/dalvikvm(800): threadid=3: reacting to signal 3
06-01 09:09:07.498: I/dalvikvm(800): Wrote stack traces to '/data/anr/traces.txt'
06-01 09:09:07.498: E/AndroidRuntime(800): FATAL EXCEPTION: main
06-01 09:09:07.498: E/AndroidRuntime(800): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{pjl.appli/pjl.appli.SoundGenActivity}: java.lang.NullPointerException
06-01 09:09:07.498: E/AndroidRuntime(800): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.os.Handler.dispatchMessage(Handler.java:99)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.os.Looper.loop(Looper.java:137)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-01 09:09:07.498: E/AndroidRuntime(800): at java.lang.reflect.Method.invokeNative(Native Method)
06-01 09:09:07.498: E/AndroidRuntime(800): at java.lang.reflect.Method.invoke(Method.java:511)
06-01 09:09:07.498: E/AndroidRuntime(800): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-01 09:09:07.498: E/AndroidRuntime(800): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-01 09:09:07.498: E/AndroidRuntime(800): at dalvik.system.NativeStart.main(Native Method)
06-01 09:09:07.498: E/AndroidRuntime(800): Caused by: java.lang.NullPointerException
06-01 09:09:07.498: E/AndroidRuntime(800): at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.view.View.<init>(View.java:2696)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.view.ViewGroup.<init>(ViewGroup.java:374)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.widget.LinearLayout.<init>(LinearLayout.java:166)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.widget.RadioGroup.<init>(RadioGroup.java:66)
06-01 09:09:07.498: E/AndroidRuntime(800): at pjl.appli.SoundGenActivity.<init>(SoundGenActivity.java:13)
06-01 09:09:07.498: E/AndroidRuntime(800): at java.lang.Class.newInstanceImpl(Native Method)
06-01 09:09:07.498: E/AndroidRuntime(800): at java.lang.Class.newInstance(Class.java:1319)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
06-01 09:09:07.498: E/AndroidRuntime(800): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
06-01 09:09:07.498: E/AndroidRuntime(800): ... 11 more
06-01 09:09:07.928: I/dalvikvm(800): threadid=3: reacting to signal 3
06-01 09:09:07.978: I/dalvikvm(800): Wrote stack traces to '/data/anr/traces.txt'
06-01 09:09:08.208: I/dalvikvm(800): threadid=3: reacting to signal 3
06-01 09:09:08.248: I/dalvikvm(800): Wrote stack traces to '/data/anr/traces.txt'
06-01 09:14:07.708: I/Process(800): Sending signal. PID: 800 SIG: 9