java - Call a new activity in android studio -


i attempting create simple app college project, becoming frustrating. every time correct error 6 more pop up. can 1 please me.

this box asking more information... create 4 activities, main, age4to10, age11to15,age15to18. need able click on button , call relative activity main.class. each time debug errors not understand how fix.

each of activities host spinner toy selection category chosen user. (don't me started on spinners)

i appreciate users not editing down post, consider information in here relevant issues having. aside.... have little java training need examples of corrections may have offer.

thanks.

package com.example.android.skillsdemovt;  import android.content.intent; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.view.view; import android.widget.button;  public class mainactivity extends appcompatactivity implements view.onclicklistener {      button button1;     button button2;     button button3;      @override      /* button1 */      protected void oncreate(bundle savedinstancestate)     {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         view viewbyid;         viewbyid = findviewbyid(r.id.button1);         button1.setonclicklistener(this);     }     @override     public void onclick1(view v)     {         {                 button1click1();         }     }     public void button1click1()     {         startactivity(new intent(mainactivity.this, age4to10.class));     }      /* button2 */      public void onclick2(view v)     {         setcontentview(r.layout.activity_main);         view viewbyid;         viewbyid = findviewbyid(r.id.button2);         button2.setonclicklistener(this);     }      public void button2click1()     {         {             button2click1();          }      }       public void()      {         {             startactivity(new intent(mainactivity.this, age11to15.class));         }     }      /* button3 */     public void onclick3(view v)     {         setcontentview(r.layout.activity_main);         view viewbyid;         viewbyid = findviewbyid(r.id.button3);         button3.setonclicklistener(this);     }     @override     public void onclick(view v) {         {             button3click1();         }      }      public void button3click1()     {         startactivity(new intent(mainactivity.this, age15to18.class));     }  }    xml   <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".mainactivity">      <imageview         android:id="@+id/tree1"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:background="@drawable/tree1"/>      <textview         android:id="@+id/welcome"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_marginbottom="85dp" android:text="welcome santa's workshop."         android:textcolor="#ffffff"         android:textsize="25sp"/>      <textview         android:id="@+id/instructions"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="please let santa know how old are!"         android:textcolor="#ffffff"         android:textsize="25sp"         android:layout_margintop="43dp"         android:layout_alignparenttop="true"         android:layout_alignright="@+id/welcome"         android:layout_alignend="@+id/welcome" />      <button         android:id="@+id/button1"         android:layout_width="120dp"         android:layout_height="120dp"         android:background="#b12b2b"         android:textcolor="#ffffff"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true"         android:layout_centervertical="true"         android:text="age 4-10"         android:textsize="30sp"         android:onclick="age4to10"/>      <button         android:id="@+id/button2"         android:layout_width="120dp"         android:layout_height="120dp"         android:background="#b12b2b"         android:textcolor="#ffffff"         android:layout_centervertical="true"         android:layout_torightof="@+id/button1"         android:text="age 11-14"         android:textsize="30sp"         android:onclick="age11to15"/>      <button         android:id="@+id/button3"         android:layout_width="120dp"         android:layout_height="120dp"         android:background="#b12b2b"         android:textcolor="#ffffff"         android:layout_centervertical="true"         android:layout_torightof="@+id/button2"         android:text="age 15-17"         android:textsize="30sp"         android:onclick="age15to18"          />      />  </relativelayout> 

try:

intent intent = new intent(storedactivity, mainactivity.class); intent.setflags(intent.flag_activity_new_task); storedactivity.startactivity(intent); this.finish(); 

Comments