在开始第三项活动时崩溃

时间:2013-05-04 20:48:47

标签: android database sqlite android-activity crash

我是android的新手。我现在有问题。我的应用程序在开始第3次活动时总是崩溃

这里是代码

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清单

    <?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”

任何人都知道这有什么不对吗?

1 个答案:

答案 0 :(得分: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>

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

相关问题