2013-07-26 5 views
1

이 android activity가 실행되지 않습니다. 아무도 나를 도울 수 있습니다. 그것은 다음 오류를 보여줍니다. 다른 활동을 시작하려면이 버튼을 클릭하면 실행되지 않습니다.android activity의 치명적인 예외

이 오류를 찾을 수 없습니다.

누구든지 고칠 수 있습니까?

오류 : 치명적인 예외 : 주요

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testingandroid/com.example.testingandroid.SumsMain}: java.lang.NullPointerException 
07-26 12:57:22.958: E/AndroidRuntime(791): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 

코드

package com.example.testingandroid; 

import android.os.Bundle; 
import android.app.Activity; 
import android.content.Intent; 
import android.view.Menu; 
import android.view.View; 
import android.widget.RadioButton; 

public class SelectTitle extends Activity implements android.view.View.OnClickListener{ 
public int entryNo; 
RadioButton r1;RadioButton r2;RadioButton r3;RadioButton r4; 
RadioButton r5;RadioButton r6;RadioButton r7;RadioButton r8; 
RadioButton r9;RadioButton r10;RadioButton r11;RadioButton r12; 
RadioButton r13; 
int determiner; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_select_title); 
     r1 = (RadioButton) findViewById(R.id.MasteryPack); 
     r2 = (RadioButton) findViewById(R.id.Simplification); 
     r3 = (RadioButton) findViewById(R.id.FractionsandRatios); 
     r4 = (RadioButton) findViewById(R.id.Number); 
     r5 = (RadioButton) findViewById(R.id.Average); 
     r6 = (RadioButton) findViewById(R.id.TimeandWork); 
     r7 = (RadioButton) findViewById(R.id.TimeandDistance); 
     r8 = (RadioButton) findViewById(R.id.Interest); 
     r9 = (RadioButton) findViewById(R.id.Measurement); 
     r10 = (RadioButton) findViewById(R.id.Percentage); 
     r11 = (RadioButton) findViewById(R.id.BoatandTrain); 
     r12 = (RadioButton) findViewById(R.id.Practice); 

     r1.setOnClickListener(this); 
     r2.setOnClickListener(this); 
     r3.setOnClickListener(this); 
     r4.setOnClickListener(this); 
     r5.setOnClickListener(this); 
     r6.setOnClickListener(this); 
     r7.setOnClickListener(this); 
     r8.setOnClickListener(this); 
     r9.setOnClickListener(this); 
     r10.setOnClickListener(this); 
     r11.setOnClickListener(this); 
     r12.setOnClickListener(this); 


    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.select_title, menu); 
     return true; 
    } 

    @Override 
    public void onClick(View v) { 
     switch (v.getId()) { 

     case R.id.MasteryPack: 
      Intent nextScreen = new Intent(getApplicationContext(), SumsMain.class); 

      nextScreen.putExtra("determiner", 1); 
      startActivity(nextScreen); 
      break; 

     case R.id.Simplification: 
      Intent nextScreen1 = new Intent(getApplicationContext(), SumsMain.class); 
      //String "determiner" = null; 
      nextScreen1.putExtra("determiner", 2); 
      startActivity(nextScreen1); 
      break; 

     case R.id.FractionsandRatios: 
      Intent nextScreen2 = new Intent(getApplicationContext(), SumsMain.class); 
      nextScreen2.putExtra("determiner", 3); 
      startActivity(nextScreen2); 
      break; 

     case R.id.Number: 
      Intent nextScreen3 = new Intent(getApplicationContext(), SumsMain.class); 
      nextScreen3.putExtra("determiner", 4); 
      startActivity(nextScreen3); 
      break; 

     case R.id.Average: 
      Intent nextScreen4 = new Intent(getApplicationContext(), SumsMain.class); 
      nextScreen4.putExtra("determiner", 5); 
      startActivity(nextScreen4); 
      break; 

     case R.id.TimeandWork: 
      Intent nextScreen5 = new Intent(getApplicationContext(), SumsMain.class); 
      nextScreen5.putExtra("determiner", 6); 
      startActivity(nextScreen5); 
      break; 

     case R.id.TimeandDistance: 
      Intent nextScreen6 = new Intent(getApplicationContext(), SumsMain.class); 
      nextScreen6.putExtra("determiner", 7); 
      startActivity(nextScreen6); 
      break; 

     case R.id.Interest: 
      Intent nextScreen7 = new Intent(getApplicationContext(), SumsMain.class); 
      nextScreen7.putExtra("determiner", 8); 
      startActivity(nextScreen7); 
      break; 

     case R.id.Measurement: 
      Intent nextScreen8 = new Intent(getApplicationContext(), SumsMain.class); 
      nextScreen8.putExtra("determiner", 9); 
      startActivity(nextScreen8); 
      break; 

     case R.id.Percentage: 
      Intent nextScreen9 = new Intent(getApplicationContext(), SumsMain.class); 
      nextScreen9.putExtra("determiner", 10); 
      startActivity(nextScreen9); 
      break; 

     case R.id.BoatandTrain: 
      Intent nextScreen10 = new Intent(getApplicationContext(), SumsMain.class); 
      nextScreen10.putExtra("determiner", 11); 
      startActivity(nextScreen10); 
      break; 

     case R.id.Practice: 
      Intent nextScreen11 = new Intent(getApplicationContext(), SumsMain.class); 
      nextScreen11.putExtra("determiner", 12); 
      startActivity(nextScreen11); 
      break; 



     }  
    } 

} 
+4

전체 스택 추적을 게시하십시오. – Raghunandan

+1

또한,'SumsMain'의'onCreate()'를 게시하십시오. 오류는 해당 클래스에서 발생할 가능성이 큽니다. – codeMagic

+0

'R.layout.activity_select_title'의 내용을 게시 할 수 있습니까? – Geros

답변

0

우리가 일반적으로 텐트를 사용하는 다른 하나 개의 활동에서 이동하려면이되는 우리의 수업 활동의 이름을 작성해야 우리가 움직이기를 원합니다.

코드에서 코드를 실행하기 전에 SumMain 클래스를 만들어야합니다. 그것은 당신이 아직 생성되지 않은 객체를 가능한 사용하는 수

+1

이 경우 예외는 'NPE'가 아닌'NoClassDefFound'입니다. 그리고 우리가 본 코드에서'putExtra()'는 NPE를 유발하지 않습니다 – codeMagic

+0

@codeMagic 당신이 옳습니다. –

0

당신이 그것을 INT 판단 선언 putExtra 키를 직접 사용할 수 있습니다 선언 필요가 없습니다

. 그것을 확인하십시오 ...