小编gan*_*aam的帖子

无法使用 WebView 打开 PDF 文件

我试图在 webview 中使用 url 显示 pdf 文件。虽然 WebView 正在加载像 google.com 这样的网页,但当我尝试加载 pdf 的 url 时,它不会加载任何内容或引发任何异常。

该网址在谷歌浏览器桌面浏览器中加载pdf,所以我猜问题不在于网址本身。

这是我到目前为止编写的代码:

onCreateView()加载 pdf 的片段

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_brochure, container, false);
        webView = view.findViewById(R.id.webView);
//        webView.loadUrl("https://google.com");
        webView.loadUrl("https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf");
//        webView.loadUrl(brochureUrl);
        // Enable Javascript
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportZoom(true);

        // Force links and redirects to open in the WebView instead of in a browser
        webView.setWebViewClient(new WebViewClient());
        return view; …
Run Code Online (Sandbox Code Playgroud)

pdf android webview

5
推荐指数
1
解决办法
8767
查看次数

更新 room、kotlin 和 ksp 版本后出现“指定为非空的参数为空”错误

我通过以下方式使用 room 在 SQLite 数据库中插入一些数据:

在repository类中插入数据的方法:

    fun addAllConfigurableTypeToDb(
        allConfigurableTypes: AllConfigurableType,
        database: AppDatabase
    ): Boolean {
        try {
            val productCategoryList = arrayListOf<ConfigurableTypeEntity>()
            for (configurableType in allConfigurableTypes.configurableTypeList) {
                productCategoryList.add(
                    ConfigurableTypeEntity(
                        configurableType.id, configurableType.classType,
                        configurableType.organizationId, configurableType.name,
                        configurableType.code, configurableType.description,
                        configurableType.context, configurableType.isActive,
                        configurableType.isLocked, configurableType.isDeleted,
                        configurableType.createdBy, configurableType.createdByDate,
                        configurableType.lastModifiedBy, configurableType.lastModifiedByDate

                    )
                )
            }
            database.configurableTypeDao.insertAll(*productCategoryList.toTypedArray())
            return true
        } catch (e: Exception) {
            e.printStackTrace()
            return false
        }
    }
Run Code Online (Sandbox Code Playgroud)

Dao类中的方法:

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertAll(vararg configurableTypeEntity: ConfigurableTypeEntity)
Run Code Online (Sandbox Code Playgroud)

它一直运行良好。但是将 room 版本从 '2.5.2' 更新到 '2.6.0'、ksp 版本从 '1.8.10-1.0.9' 更新到 '1.9.20-1.0.14' 以及 kotlin 版本从 '1.8.10' …

android kotlin android-room

5
推荐指数
1
解决办法
323
查看次数

无法解析符号'FloatingActionButton'

最近我从git-hub下载了一个代码并将其同步到我的android工作室.我遇到了很多错误和问题,然后修复了它们.然而,我现在停留的最后一个问题是我的android工作室不能像你在这张图片中看到的类'FloatingActionButton'

需要注意的是,早期的许多其他类,包括'AppCompatActivity'都无法解决.将依赖项更改为以下解决了该问题

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'}
Run Code Online (Sandbox Code Playgroud)

但即使在更改依赖项后,清理构建项目,执行"使缓存无效/重新启动...","FloatingActionButton"的问题仍然存在.任何人都可以帮我解决这个问题吗?
这是存储库的链接,
这里是发生错误 的活动java代码

java android android-studio floating-action-button

4
推荐指数
1
解决办法
5909
查看次数

发生未处理的异常:项目目标不存在

我写的时候遇到一个问题:

\n

ionic cordova prepare android\xd8\x8c

\n

知道我创建的每个新项目都会发生这种情况。\n请帮忙。

\n

截屏

\n

android cordova ionic-framework ionic4

4
推荐指数
1
解决办法
5219
查看次数

Python - 如何解析 xml 响应并将元素值存储在变量中?

我从 API 调用获取 XML 响应。

我需要此响应中的“testId”属性值。请帮我解决这个问题。

r = requests.get( myconfig.URL_webpagetest + "?url=" + testurl + "&f=xml&k=" + myconfig.apikey_webpagetest )
xmltxt = r.content
print(xmltxt)
testId = XML(xmltxt).find("testId").text
r = requests.get("http://www.webpagetest.org/testStatus.php?f=xml&test=" + testId )
Run Code Online (Sandbox Code Playgroud)

xml响应:

xml响应截图

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <statusCode>200</statusCode>
    <statusText>Ok</statusText>
    <data>
        <testId>180523_YM_054fd7d84fd4ea7aed237f87289e0c7c</testId>
        <ownerKey>dfc65d98de13c4770e528ef5b65e9629a52595e9</ownerKey>
        <jsonUrl>http://www.webpagetest.org/jsonResult.php?test=180523_YM_054fd7d84fd4ea7aed237f87289e0c7c</jsonUrl>
    </data>
</response>
Run Code Online (Sandbox Code Playgroud)

产生以下错误:

Traceback (most recent call last):
  File "/pagePerformance.py", line 52, in <module>
    testId = XML (xmltxt).find("testId").text
AttributeError: 'NoneType' object has no attribute 'text'
Run Code Online (Sandbox Code Playgroud)

python xml parsing xml-parsing

2
推荐指数
1
解决办法
2万
查看次数

C将char数组初始化为字符串但在尝试printf时为空

我想打印字符数组(作为字符串),但它在运行时显示一个空字符串

初始化:

    char str1[6]= "Black";
    char str2[7]= "Yellow";
Run Code Online (Sandbox Code Playgroud)

printf 语句:

    printf ("%s = %d Bath\n",str1,a);
    printf ("%s = %d Bath\n",str2,a);
Run Code Online (Sandbox Code Playgroud)

预期的:

Black = 150 Bath
Yellow = 150 Bath
Run Code Online (Sandbox Code Playgroud)

输出

Black = 150 Bath
  = 150 Bath
Run Code Online (Sandbox Code Playgroud)

我尝试在没有大小数字的情况下进行初始化,例如char str2[]= "Yellow"; 或使用 C++ cout 来显示

原始代码:

    char str1[6]= "Black";
    char str2[7]= "Yellow";
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
60
查看次数