0

MainActivity と ReadActivity の 2 つのアクティビティがあります。

MainActivity から ReadActivity を開始するたびに、Activity は開始されましたが、何も表示されず、マニフェスト ファイルの android:label 値だけが表示されます。

調査中に、ReadActivity に Log を入れてみましたが、メソッドをオーバーライドするのを忘れたため、OnCreate メソッドが呼び出されていないことに気付きましたが、OnCreate メソッドの上に「@Override」を置くと、次のエラーが発生します。

「タイプ ReadActivity のメソッド OnCreate(Bundle) は、スーパータイプ メソッドをオーバーライドまたは実装する必要があります」。

この行の何が問題なのかわかりません。コードを他のアプリケーションのコードと比較して何度もチェックしましたが、オーバーライドできないようです。誰でも私を助けることができますか?以下は私のプロジェクトのコードです。

主な活動

package com.rangga.elearning.ngaji;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity{
    /** Called when the activity is first created. */

    TextView txtLogo, txtVersion;
    Button btnRead, btnIndex, btnAbout;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.main);

        //Typeface font =  Typeface.createFromAsset(getAssets(), "assets/Schoolbell.ttf");

        txtLogo = (TextView) findViewById(R.id.txtLogo);
        txtVersion = (TextView) findViewById(R.id.txtVersion);
        btnRead = (Button) findViewById(R.id.btnRead);
        btnIndex = (Button) findViewById(R.id.btnIndex);
        btnAbout = (Button) findViewById(R.id.btnAbout);

        /* txtLogo.setTypeface(font);
        txtVersion.setTypeface(font);
        btnRead.setTypeface(font);
        btnIndex.setTypeface(font);
        btnAbout.setTypeface(font); */

        btnRead.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                callIntent();
            }
        });
    }

    public void callIntent(){
        Intent i = new Intent(this, ReadActivity.class);
        startActivity(i);
    }
}

読み取りアクティビティ

package com.rangga.elearning.ngaji;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

public class ReadActivity extends Activity{

    private static String TAG = "ReadActivity";

    @Override
    public void OnCreate(Bundle savedInstanceState){        

        Log.i(TAG, "ReadActivity dimulai");
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.read);          
    }

}

AndroidManifest.xml

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

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity 
            android:name=".ReadActivity"
            android:label="Baca"
            android:screenOrientation="landscape">

        </activity>
    </application>

</manifest>

ありがとうございました。

4

1 に答える 1

1

onCreate()ありませんOnCreate()Intentさらに、マニフェストにはReadActivity.

于 2012-05-15T13:45:38.263 に答える