gpt4 book ai didi

java - 为 webview 实现闪屏时出错

转载 作者:行者123 更新时间:2023-11-30 11:44:20 26 4
gpt4 key购买 nike

我正在尝试为我的 webview android 应用程序实现启动画面,以便它会一直显示到页面完全加载为止。我使用的是已接受答案中的代码 here但遇到了一些我不确定如何解决的错误。我假设我缺少某种类型的库,但我不知道是什么。

我得到的错误是:

View cannot be resolved to a variable

error: Error: No resource found that matches the given name (at 'src' with value @drawable/vert_loading')

出现 View 错误的代码是:

webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
findViewById(R.id.imageLoading1).setVisibility(View.GONE);
findViewById(R.id.webview).setVisibility(View.VISIBLE);
}
});

虽然我的布局 xml 文件是:

<ImageView
android:id="@+id/imageLoading1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:visibility="visible"
android:src="@drawable/vert_loading"
/>

我的假设是我可能缺少某种导入,但我不知道是哪一个。我有的是:

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;

如有任何帮助,我们将不胜感激。

最佳答案

File->New->Folder 在您的项目 res 中添加一个 drawable 文件夹并将您的 drawable vert_loading 在 res->drawable 文件夹中。然后从 Project->Clean 清理你的项目。

关于java - 为 webview 实现闪屏时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10804157/

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