Android 开空 activity 开始新的时候 activity

Android open empty activity when starting new activity

我正在尝试制作一个简单的测验应用程序

用户可以回答问题并按"next question"按钮,直到他到达最后一个问题。当他按下按钮时,Android 应该显示一个包含结果的新 Activity

但问题就在这里。当我试用该应用程序时,它显示的是空的 Activity

这是我的代码:

AndroidManifest.xml :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.quizapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".Quiz"
        android:label="@string/app_name" >

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

 <activity
        android:name=".Result"
        android:label="@string/app_name" >

        <intent-filter>
            <action android:name="MySecond" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>      

</application>

</manifest>

Quiz.java :

package com.example.quizapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

public class Quiz extends Activity {

TextView tv;
Button nxt ;
RadioGroup rg;
RadioButton r1 , r2 , r3 ;

String question [] = {"your name ?","your age?"};
String ans[] = {"Tareq","22"};
String opt []= {"moh","Tareq","khaled","22","21","20"};

int flag = 0 ; 
public static int marks , correct , wrong ;


 public void onCreate(Bundle b) {
        super.onCreate(b);
        setContentView(R.layout.quiz);

        tv=(TextView)findViewById(R.id.question);
        nxt=(Button)findViewById(R.id.button1);
        rg=(RadioGroup)findViewById(R.id.radioGroup1);
        r1=(RadioButton)findViewById(R.id.radio1);
        r2=(RadioButton)findViewById(R.id.radio2);
        r3=(RadioButton)findViewById(R.id.radio3);


        tv.setText(question[flag]);
        r1.setText(opt[0]);
        r2.setText(opt[1]);
        r3.setText(opt[2]);

        nxt.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                RadioButton selectedAns = (RadioButton)findViewById(rg.getCheckedRadioButtonId());
                String selectedAnsText = selectedAns.getText().toString();

                if (selectedAnsText.equals(ans[flag])){

                    correct ++ ;
                }
                else {
                    wrong ++ ; 
                }
                flag ++ ;

                if ( flag < question.length)
                {
                    tv.setText(question[flag]);
                    r1.setText(opt[flag*3]);
                    r2.setText(opt[flag*3]+1);
                    r3.setText(opt[flag*3]+2);

                }
                else {

                    marks = correct - wrong ;
                    startActivity (new Intent("MySecond"));
                }

            }
        });

    }
}

Result.java :

 package com.example.quizapp;

 import android.app.Activity;
 import android.os.Bundle;
 import android.widget.TextView;

 public class Result extends Activity{

TextView tv ; 


public void OnCreate(Bundle b){

    super.onCreate(b);
    setContentView(R.layout.result);


    tv = (TextView) findViewById(R.id.result);
    tv.setText("your final result is :");
}

}

quiz.xml : 没问题

result.xml :

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical" >

<TextView
    android:id="@+id/result"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

  </LinearLayout>

那么问题出在哪里呢?

提前致谢..

在你的Result.java改变

public void OnCreate(Bundle b){public void onCreate(Bundle b){

注意 onCreate 中的 o。应该是小号的。