gpt4 book ai didi

java - Activity_splash 无法解析或者它不是 Android 应用程序中的字段

转载 作者:行者123 更新时间:2023-12-02 04:20:30 25 4
gpt4 key购买 nike

下面是我的activity_splash.xml布局和manifest.xml。当我在 java 代码中使用 setContentView(R.layout.activity_splash) 时,它给我错误(activity_splash 无法解析或它不是一个字段)。 R.java 中没有对此 xml 文件的引用。我的代码有问题吗。我只做了两处更改,之后就出现了这个错误。这就是我在这里发布这两个文件的原因。我想做的是在应用程序启动时通过显示闪屏来加载 web View 中的 URL。

activity_splash.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffff0000 >

<ImageView
android:id="@+id/imgLogo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:src="@drawable/nricabs"
android:contentDescription="@string/app_name" />

<TextView
android:id="@+id/url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textSize="22sp"
android:layout_alignParentBottom="true"
android:text="@string/url" />
</RelativeLayout>

ma​​nifest.xml

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

<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@drawable/nricabs"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
//activity_splash.xml is used in seperate SplashScreen.java file

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

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
</application>

</manifest>

以及如何在显示闪屏的同时实现 webview 背景中的 url 加载。我的方法正确吗?

最佳答案

试试这个,

下一行中缺少“(双引号)。

android:background="#ffff0000"

以下是您编辑的xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffff0000" >

<ImageView
android:id="@+id/imgLogo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:src="@drawable/nricabs"
android:contentDescription="@string/app_name" />

<TextView
android:id="@+id/url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textSize="22sp"
android:layout_alignParentBottom="true"
android:text="@string/url" />
</RelativeLayout>

关于java - Activity_splash 无法解析或者它不是 Android 应用程序中的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32821866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com