0

我是安卓新手。我现在有问题。开始第三个活动时,我的应用程序总是崩溃

这是代码

package com.example.anagramgame;

import android.app.Activity;
import android.os.Bundle;
import android.database.Cursor;
import android.widget.Toast;



public class Level_list extends Activity{

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.level_list);

        DBAdapter db = new DBAdapter(this);

        db.open();
        Cursor c = db.getAllQuestions();
        if(c.moveToFirst())
        {
            do
            {
                DisplayTitle(c);
            }while (c.moveToNext());
        }
        db.close();
    }

    public void DisplayTitle(Cursor c)
    {
        Toast.makeText(this, 
                        "id: " + c.getString(0) + "\n" +
                        "answer: " + c.getString(1) + "\n" +
                        "question: " + c.getString(2) + "\n" +
                        "hint: " + c.getString(3) + "\n" +
                        "flag: " + c.getString(4) + "\n" +
                        "Level:" + c.getString(5), Toast.LENGTH_LONG).show();
    }
}

这是xml

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

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/background" >

     <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dip" 
        android:gravity="left">
             <ImageButton 
                    android:id="@+id/home_button"
                    android:background="@drawable/home_button"
                    android:layout_width="45dip"
                    android:layout_height="50dip" 
                    />
      </TableRow>

</TableLayout>

</ScrollView>

最后这是 android manifest

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

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="14" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.anagramgame.Main"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/FullscreenTheme" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

    </application>

</manifest>

在 logcat 上写着“消息:无法加载项目 anagramGame 的文件。插件:com.android.ide.eclipse.adt”

有人知道这有什么问题吗?

4

1 回答 1

0

您的清单中似乎存在问题,您可以像这样定义您的活动并查看这是否解决了您的问题:

            android:theme="@style/Theme.Transparent" >
            <intent-filter>
                <action android:name="com.example.anagramgame.Level_list" />
                  android:theme="@style/FullscreenTheme"
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

当您调用此第三个活动时,将意图名称设置为“com.example.anagramgame.Level_list”

于 2013-05-04T22:45:07.450 回答