3つのラジオボタンとテキストビューを備えたダイアログアラートボックスを作成しようとしていますが、3つのラジオボタンを使用して実行しようとすると、テキストビューを追加すると、アプリケーションに例外が表示されます。
private void Dialog(){
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
// tv1=new TextView(this);
// rb1.setText("these are the time limit options for you");
rb1=new RadioButton(this);
rb1.setText("10 minutes");
rb2=new RadioButton(this);
rb2.setText("20 minutes");
rb3=new RadioButton(this);
rb3.setText("30 minutes");
rb1.setOnClickListener(RadioOptionOnClickListener);
rb2.setOnClickListener(RadioOptionOnClickListener);
rb3.setOnClickListener(RadioOptionOnClickListener);
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT));
linearLayout.setOrientation(1);
private void Dialog(){
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
// tv1=new TextView(this);
// rb1.setText("these are the time limit options for you");
rb1=new RadioButton(this);
rb1.setText("10 minutes");
rb2=new RadioButton(this);
rb2.setText("20 minutes");
rb3=new RadioButton(this);
rb3.setText("30 minutes");
rb1.setOnClickListener(RadioOptionOnClickListener);
rb2.setOnClickListener(RadioOptionOnClickListener);
rb3.setOnClickListener(RadioOptionOnClickListener);
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT));
linearLayout.setOrientation(1);
// linearLayout.addView(tv1);
linearLayout.addView(rb1);
linearLayout.addView(rb2);
linearLayout.addView(rb3);
alertDialog.setView(linearLayout);
alertDialog.show();
}
これは例外です
07-15 16:23:30.081: W/dalvikvm(1129): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-15 16:23:30.248: E/AndroidRuntime(1129): FATAL EXCEPTION: main
07-15 16:23:30.248: E/AndroidRuntime(1129): java.lang.NullPointerException
07-15 16:23:30.248: E/AndroidRuntime(1129): at test.test.AlertdialogActivity.Dialog(AlertdialogActivity.java:32)
07-15 16:23:30.248: E/AndroidRuntime(1129): at test.test.AlertdialogActivity.access$0(AlertdialogActivity.java:29)
07-15 16:23:30.248: E/AndroidRuntime(1129): at test.test.AlertdialogActivity$1.onClick(AlertdialogActivity.java:59)
07-15 16:23:30.248: E/AndroidRuntime(1129): at android.view.View.performClick(View.java:2485)
07-15 16:23:30.248: E/AndroidRuntime(1129): at android.view.View$PerformClick.run(View.java:9080)
07-15 16:23:30.248: E/AndroidRuntime(1129): at android.os.Handler.handleCallback(Handler.java:587)
07-15 16:23:30.248: E/AndroidRuntime(1129): at android.os.Handler.dispatchMessage(Handler.java:92)
07-15 16:23:30.248: E/AndroidRuntime(1129): at android.os.Looper.loop(Looper.java:123)
07-15 16:23:30.248: E/AndroidRuntime(1129): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-15 16:23:30.248: E/AndroidRuntime(1129): at java.lang.reflect.Method.invokeNative(Native Method)
07-15 16:23:30.248: E/AndroidRuntime(1129): at java.lang.reflect.Method.invoke(Method.java:507)
07-15 16:23:30.248: E/AndroidRuntime(1129): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-15 16:23:30.248: E/AndroidRuntime(1129): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-15 16:23:30.248: E/AndroidRuntime(1129): at dalvik.system.NativeStart.main(Native Method)
この問題の解決方法を教えてください。よろしくお願いします。