title: Android: using radiobutton in new intent
body: <p>I'm self studying in the hope that I can be a good developer. I am currently writing a program where I can use menus to change the background colour for my own knowledge. Once this works, I will then decide if this should be part of my actual program.I have currently created a toolbar in my MainActivity. I have written an intent in the toolbar to launch a second activity. I now wish to create a RadioButton which allows me to change the colour of the background, the same way developers allow us to customize settings of programs we obtain from Google play store. I am unsure where to insert my codes and it crashes whether I try inserting in the submenus or in the java file. Are there any tutorials for this? My codes as below to show what I tried. My logcat is also there but I'm not sure how to read it or what to search for as I'm still new.</p>
  
  <pre><code>public class SecondActivity extends AppCompatActivity {
  
      RadioButton radio_cyan;
      View root;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.second_activity);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
  
          if (id == R.id.change_colour) {
              Intent intent = new Intent(this,MainActivity.class);
              startActivity(intent);
              root.setBackgroundColor(Color.CYAN);
              return true;
          }
  
          if (id == R.id.action_search) {
              Toast.makeText(this, "Android Menu is Clicked", Toast.LENGTH_LONG).show();
              return true;
          }
  
          if (id == R.id.action_settings) {
              Toast.makeText(this, "Android Menu is Clicked", Toast.LENGTH_LONG).show();
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
  }
  
  
      &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          tools:context=".MainActivity"&gt;
  
          &lt;item
              android:id="@+id/action_search"
              android:orderInCategory="100"
              android:title="Search"
              app:actionViewClass="android.support.v7.widget.SearchView"
              app:showAsAction="ifRoom"
              android:icon="@android:drawable/ic_menu_search"/&gt;
          &lt;item
              android:id="@+id/action_settings"
              android:title="Setting"
              app:showAsAction="never" /&gt;
          &lt;item
              android:id="@+id/change_colour"
              android:title="Change colour"
              app:showAsAction="never" /&gt;
  
      &lt;/menu&gt;
  </code></pre>
  
  <p>03-23 13:33:30.117 2220-2220/com.example.menuitem_toolbar_test I/dalvikvm-heap: Grow heap (frag case) to 3.782MB for 635808-byte allocation
  03-23 13:33:30.317 2220-2226/com.example.menuitem_toolbar_test D/dalvikvm: GC_FOR_ALLOC freed 105K, 9% free 3715K/4064K, paused 196ms, total 196ms
  03-23 13:33:31.517 2220-2220/com.example.menuitem_toolbar_test I/Choreographer: Skipped 204 frames!  The application may be doing too much work on its main thread.
  03-23 13:33:32.917 2220-2220/com.example.menuitem_toolbar_test D/EGL_emulation: eglMakeCurrent: 0xb914fef0: ver 2 0
  03-23 13:33:33.847 2220-2220/com.example.menuitem_toolbar_test I/Choreographer: Skipped 123 frames!  The application may be doing too much work on its main thread.
  03-23 13:33:34.997 2220-2220/com.example.menuitem_toolbar_test D/EGL_emulation: eglMakeCurrent: 0xb914fef0: ver 2 0
  03-23 13:33:35.307 2220-2220/com.example.menuitem_toolbar_test I/Choreographer: Skipped 32 frames!  The application may be doing too much work on its main thread.
  03-23 13:33:35.427 2220-2220/com.example.menuitem_toolbar_test D/EGL_emulation: eglMakeCurrent: 0xb914fef0: ver 2 0
  03-23 13:33:35.687 2220-2220/com.example.menuitem_toolbar_test D/EGL_emulation: eglMakeCurrent: 0xb914fef0: ver 2 0
  03-23 13:33:35.937 2220-2220/com.example.menuitem_toolbar_test D/EGL_emulation: eglMakeCurrent: 0xb914fef0: ver 2 0
  03-23 13:33:41.077 2220-2220/com.example.menuitem_toolbar_test W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
  03-23 13:33:41.217 2220-2220/com.example.menuitem_toolbar_test I/Choreographer: Skipped 44 frames!  The application may be doing too much work on its main thread.
  03-23 13:33:43.537 2220-2220/com.example.menuitem_toolbar_test D/EGL_emulation: eglMakeCurrent: 0xb914fef0: ver 2 0
  03-23 13:33:44.857 2220-2220/com.example.menuitem_toolbar_test D/EGL_emulation: eglMakeCurrent: 0xb914fef0: ver 2 0
  03-23 13:33:47.157 2220-2220/com.example.menuitem_toolbar_test D/EGL_emulation: eglMakeCurrent: 0xb914fef0: ver 2 0
  03-23 13:33:47.427 2220-2220/com.example.menuitem_toolbar_test D/AndroidRuntime: Shutting down VM
  03-23 13:33:47.457 2220-2220/com.example.menuitem_toolbar_test W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xaf865b20)
  03-23 13:33:47.487 2220-2220/com.example.menuitem_toolbar_test E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                   Process: com.example.menuitem_toolbar_test, PID: 2220
                                                                                   java.lang.IllegalStateException: Could not find method onClick(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatRadioButton with id 'radio_cyan'
                                                                                       at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:327)
                                                                                       at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:284)
                                                                                       at android.view.View.performClick(View.java:4438)
                                                                                       at android.widget.CompoundButton.performClick(CompoundButton.java:100)
                                                                                       at android.view.View$PerformClick.run(View.java:18422)
                                                                                       at android.os.Handler.handleCallback(Handler.java:733)
                                                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                       at android.os.Looper.loop(Looper.java:136)
                                                                                       at android.app.ActivityThread.main(ActivityThread.java:5017)
                                                                                       at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                       at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                                                                       at dalvik.system.NativeStart.main(Native Method)
  03-23 13:33:55.907 2220-2220/? I/Process: Sending signal. PID: 2220 SIG: 9</p>