java - setContentView() in android causing crash -


i callling mainactivity.java file file named intro.java when first created app project, mainactivity.java main file. later on, changed manifest.xml placing intent-filter in .intro activity.

my intro.java has 2 buttons, of quiz button not working, though facts button works. calling mainactivity.java quiz button through intent. have used log.v find error. app reaches till before setcontentview() method in mainactivity.java after crashes. please help.

intro.java

package com.example.aasiq.quizapp;  import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.textview;  public class intro extends appcompatactivity {      textview t;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_intro);      t = (textview) findviewbyid(r.id.text);      }      public void q(view v){          intent = new intent(this,mainactivity.class);         log.v("tag","before startactivity");         startactivity(i);     }      public void f(view v){         intent = new intent(this,facts.class);         startactivity(i);      }  } 

mainactivity.java

package com.example.aasiq.quizapp;  import android.content.intent; import android.media.image; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.imageview; import android.widget.radiobutton; import android.widget.textview; import android.widget.toast;  public class mainactivity extends appcompatactivity {      imageview image;     int i=0,j=0,k=0,score=0,c=0;     textview t ;     radiobutton r1,r2,r3,r4;     string question[]= {"q1: name?","q2: when bday",     "q3: remember first train ride?  "};     string correct[]={"akshay","october","yes"};     string answer[] = {"akshay","rishi","harsh","aditya","nov","dec","march","oct","yes","no","dont know","yupz"};      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         log.v("tag","i have reached quiz mainactivity");         setcontentview(r.layout.activity_main);          log.v("tag","after quiz mainactivity");         t = (textview) findviewbyid(r.id.textview3);         r1 = (radiobutton) findviewbyid(r.id.radiobutton);         r2 = (radiobutton) findviewbyid(r.id.radiobutton2);         r3 = (radiobutton) findviewbyid(r.id.radiobutton3);         r4 = (radiobutton) findviewbyid(r.id.radiobutton4);          t.settext(question[j]);         r1.settext(answer[i]);         r2.settext(answer[i+1]);         r3.settext(answer[i+2]);         r4.settext(answer[i+3]);      }      public void check(view v){           switch (v.getid()){              case r.id.radiobutton :                 if(r1.gettext() == correct[k]) {                     toast.maketext(this, "correct answer, click on next" , toast.length_short).show();                     score++;                     r1.setenabled(false);                     r2.setenabled(false);                     r3.setenabled(false);                     r4.setenabled(false);                     break;                 }                 else {                     toast.maketext(this, "wrong answer, choose another", toast.length_short).show();                 break;                 }             case r.id.radiobutton2 :                 if(r2.gettext() == correct[k]) {                     toast.maketext(this, "correct answer, click on next" , toast.length_short).show();                     score++;                     r1.setenabled(false);                     r2.setenabled(false);                     r3.setenabled(false);                     r4.setenabled(false);                      break;                  }                 else {                     toast.maketext(this, "wrong answer, choose another", toast.length_short).show();                 break;                 }               case r.id.radiobutton3 :                 if(r3.gettext() == correct[k]) {                     toast.maketext(this, "correct answer, click on next" , toast.length_short).show();                     score++;                     r1.setenabled(false);                     r2.setenabled(false);                     r3.setenabled(false);                     r4.setenabled(false);                     break;                 }                 else {                     toast.maketext(this, "wrong answer, choose another", toast.length_short).show();                 break;                 }              case r.id.radiobutton4 :                 if(r4.gettext() == correct[k]) {                     toast.maketext(this, "correct answer, click on next" , toast.length_short).show();                     score++;                     r1.setenabled(false);                     r2.setenabled(false);                     r3.setenabled(false);                     r4.setenabled(false);                     break;                 }                 else {                     toast.maketext(this, "wrong answer, choose another", toast.length_short).show();                 break;                 }         }       }      public void next(view v){          r1.setenabled(true);         r2.setenabled(true);         r3.setenabled(true);         r4.setenabled(true);          i=i+4;         j++;         k++;         c++;          if(c == 3)         {             intent = new intent(this,finish.class);             i.putextra("tag",score);             startactivity(i);         }  t.settext(question[j]);             r1.settext(answer[i]);         r2.settext(answer[i+1]);         r3.settext(answer[i+2]);         r4.settext(answer[i+3]);        }  } 

manifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.aasiq.quizapp">      <application         android:allowbackup="true"         android:icon="@mipmap/ic_launcher"         android:label="@string/app_name"         android:roundicon="@mipmap/ic_launcher_round"         android:supportsrtl="true"         android:theme="@style/apptheme">         <activity android:name=".intro">             <intent-filter>                 <action android:name="android.intent.action.main" />                 <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity>         <activity android:name=".mainactivity"/>         <activity android:name=".finish" />         <activity android:name=".facts"></activity>     </application>  </manifest> 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -