小编Har*_*hit的帖子

缺少样式,在android studio中使用CardView

使用CardView作为xml文件中的根布局(对于自定义视图),我从android studio-

缺少样式时收到错误.是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用.无法在当前主题中找到ID为0x7fff000e的样式.

我尝试为布局选择不同的主题,似乎没有任何工作.
我在我的应用中使用了新的appCompatActivity.
任何主题都适用于旧的ActionBarActivity.

android android-studio

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

使用JsonArray vs ArrayList作为RecyclerView Adapter的数据集

我已经使用了ArrayList<>JsonArray作为适配器中的数据集.我发现的一个主要区别是适配器中本地数据的数据集更改没有反映在JsonArray的调用类中.

我想知道哪一个更好,我的观察是正确的.

此外,如果我的数据集涉及从Web服务中提取数据(这给我提供Json表单数据),那么我将其更改为ArrayList <>会更好.

android recycler-adapter android-recyclerview

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

打开下载文件夹中的文件 Android N(API 24+)

我想要的只是在我的外部下载目录中打开一个 pdf 文件。

我使用这段代码打开该文件,并且它曾经工作正常。

File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
            + File.separator + filename);
    Uri path = Uri.fromFile(file);
    Intent pdfOpenintent = new Intent(Intent.ACTION_VIEW);
    pdfOpenintent.setDataAndType(path, "application/" + getExtension(filename));
    pdfOpenintent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    try {
        CourseModulesActivity.this.startActivity(pdfOpenintent);
    } catch (ActivityNotFoundException e) {
        pdfOpenintent.setType("application/*");
        startActivity(Intent.createChooser(pdfOpenintent, "No Application found to open File - " + filename));
    }
Run Code Online (Sandbox Code Playgroud)

现在在 android N(API 24+) 中,它崩溃了android.os.FileUriExposedException

我按照链接 - /sf/answers/2720062831/https://developer.android.com/training/secure-file-sharing/share-file.html#ShareFile将我的代码转换为此-

File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
            + File.separator + filename);
    Uri path = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", file);
    Intent pdfOpenintent = …
Run Code Online (Sandbox Code Playgroud)

android

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