Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在我的应用程序中解决此错误?_Java_Android_Xml - Fatal编程技术网

Java 如何在我的应用程序中解决此错误?

Java 如何在我的应用程序中解决此错误?,java,android,xml,Java,Android,Xml,AndroidManifest.xml: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.saptarshi.railwayservices"> <uses-permission android:name="android.permissio

AndroidManifest.xml

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

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_train_black_24dp"
        android:label="@string/app_name"
        android:roundIcon="@drawable/ic_train_black_24dp"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name=".splashScreen"
            android:theme="@android:style/Theme.NoTitleBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Index"
            android:label="@string/title_activity_index"
            android:theme="@style/AppTheme.NoActionBar">

        </activity>
        <activity android:name=".pnrStatus" />
        <activity android:name=".liveTrain" />
        <activity android:name=".seatAvailability" />

    </application>

</manifest>
现在,当我在手机上运行此功能时,它在第行显示错误
setContentView(R.layout.activity\u启动屏幕)代码。
但是当我移除启动屏幕时,整个应用程序运行得非常完美。我也用线程来执行。但仍然显示错误:

java.lang.RuntimeException:无法启动活动 ComponentInfo{com.example.saptashi.railwayservices/com.example.saptashi.railwayservices.splashScreen}: java.lang.IllegalStateException:您需要使用Theme.AppCompat 此活动的主题(或后代)


这是因为您不使用从
theme.AppCompat
派生的主题。在
splashScreen
中,将以下属性添加到
AndroidManifest.xml
时,使用的是活动主题而不是AppCompatActivity主题:

android:theme="@android:style/Theme.NoTitleBar">
所以,你需要使用正确的一个。您可以使用:

android:theme="@style/AppTheme.NoActionBar">
那么应该是这样的,

    <activity android:name=".splashScreen"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".pnrStatus" />
    <activity android:name=".liveTrain" />
    <activity android:name=".seatAvailability" />
这意味着活动隐式使用应用程序主题。在您的情况下,活动将使用
android:theme=“@style/AppTheme”
。它来自以下代码:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_train_black_24dp"
    android:label="@string/app_name"
    android:roundIcon="@drawable/ic_train_black_24dp"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

  ...

</application>

...

Post logcat error显示了什么错误?能否从布局“android:background=“@drawable/launcher”tools:context=“com.example.saptarshi.railwayservices.splashScreen”和“android:theme=“@android:style/theme.NoTitleBar”中删除这些行'从清单中尝试?@udit7395尝试了您的方法,但仍然出现错误您是否从清单中删除了“android:theme=“@android:style/theme.NoTitleBar”?我的意思是从splashScreenActivity以及索引活动中删除。
    <activity android:name=".pnrStatus" />
    <activity android:name=".liveTrain" />
    <activity android:name=".seatAvailability" />
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_train_black_24dp"
    android:label="@string/app_name"
    android:roundIcon="@drawable/ic_train_black_24dp"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

  ...

</application>