简体   繁体   English

Android编程未在模拟器中显示,请阅读其他问题,仍然没有解决方案

[英]Android Programming Not Showing up in Emulator, Read other questions, still no solution

For my Android App, I've declared multiple Activities in the AndroidManifest.xml file. 对于我的Android应用程序,我在AndroidManifest.xml文件中声明了多个Activity。

The AndroidManifest.xml file is AndroidManifest.xml文件是

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/quizicon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" android:debuggable="true">

        <activity android:name="QuizActivity"

            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="QuizSplashActivity"> </activity>
        <activity android:name="QuizGameActivity"> </activity>
        <activity android:name="QuizHelpActivity"> </activity>
        <activity android:name="QuizMenuActivity"> </activity>
        <activity android:name="QuizScoresActivity"> </activity>
        <activity android:name="QuizSettingsActivity"> </activity>

    </application>

</manifest>

For some reason, my App never shows up on the Emulator. 由于某些原因,我的应用程序永远不会显示在模拟器上。 I've read the answers of other people asking the same question, but my App still does not show. 我已经阅读了其他人问同样问题的答案,但我的应用程序仍然没有显示。 I do not get any Compilation or Running Errors. 我没有收到任何编译或运行错误。

If it's any help, my QuizActivity.java file is 如果有帮助,我的QuizActivity.java文件是

package com.example.btdt;

import android.os.Bundle;
import android.app.Activity;
import android.content.SharedPreferences;
import android.view.Menu;
import android.widget.TextView;

public class QuizActivity extends Activity {
    TextView countDisplay;

    public static final String GAME_PREFERENCES = "GamePrefs";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_quiz_splash);

        SharedPreferences settings =
                getSharedPreferences(GAME_PREFERENCES, MODE_PRIVATE);
        SharedPreferences.Editor prefEditor = settings.edit();
        prefEditor.putString("UserName", "Ryan D'souza");
        prefEditor.putInt("UserAge", 16);
        prefEditor.commit();

        countDisplay = new TextView(this);
        this.setContentView(countDisplay);

        if(settings.contains("UserName") == true)
        {
            String user = settings.getString("UserName", "Default");
            countDisplay.setText(user);

        }
    }

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

}

Thank you for your help 谢谢您的帮助

Try To declare your other activities like that: 尝试声明您的其他活动,例如:

    <activity
        android:name=".YourClass"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.your.package.name" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

If the emulator does not show it, restart Eclipse and open it. 如果仿真器未显示它,请重新启动Eclipse并打开它。 Before to run the app, open the emulator and wait still it load. 在运行该应用程序之前,请打开模拟器并等待其加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM