小编Pri*_*iya的帖子

在Glide v4中区别DiskCacheStrategy

我在我的一个Android应用程序中使用Glide 4.1.1.我使用下面的代码,并没有在应用程序中遇到任何问题.

Glide.with(context)
                .load(constant.BASE_URL+"images/"+data.getPicture())
                .apply(new RequestOptions()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .dontAnimate()
                .centerCrop()
                .dontTransform())
                .into(holder.imageView);
Run Code Online (Sandbox Code Playgroud)

我对.diskCacheStrategy(DiskCacheStrategy.ALL)选项有疑问.总共有五种类型选项,如下所示

.diskCacheStrategy(DiskCacheStrategy.ALL)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.diskCacheStrategy(DiskCacheStrategy.DATA)
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
Run Code Online (Sandbox Code Playgroud)

我试图找到它的文档,但无法找到它之间的区别.让我知道是否有人使用它并知道这一切之间的区别是什么以及何时应该使用它.谢谢

java android android-glide

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

错误:(39,13)无法解决:com.android.support:appcompat-v7:26.0.0

我在我的应用程序中使用Android工作室2.3和思考支持新的Android 26但是我在标题消息上遇到错误.我的gradle文件如下所示

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"



    defaultConfig {
        applicationId "com.example.shayari"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"

        manifestPlaceholders = [onesignal_app_id               : "",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "REMOTE"]

        vectorDrawables.useSupportLibrary = true
    }



    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.google.android.gms:play-services-location:10.2.6'
    compile 'com.android.support:support-v4:26.0.0'
    compile 'com.google.android.gms:play-services-gcm:10.2.6'
    compile 'com.google.android.gms:play-services-ads:10.2.6'
    compile 'com.android.support:appcompat-v7:26.0.0'
    compile 'com.android.support:preference-v7:26.0.0'
    compile 'com.android.support:design:26.0.0'
    compile 'com.android.support:cardview-v7:26.0.0'
    compile …
Run Code Online (Sandbox Code Playgroud)

android

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

方法调用可能会产生NullPointerException Retrofit Body

我正在使用Retrofit 2从我的API获取响应并将其值存储在我的常量中,如下所示

if(response.isSuccessful()) {
                    constant.banner_on = response.body().getBanner_on();
                    constant.int_on = response.body().getInt_on();
                    constant.int_click = response.body().getInt_click();
                }
Run Code Online (Sandbox Code Playgroud)

它给了我三个警告,如下所示

Method invocation getBanner_on may produce java.lang.nullPointerException
Run Code Online (Sandbox Code Playgroud)

我很困惑,无法解决此警告.让我知道是否有人可以帮我从这里出来.

谢谢

java android retrofit retrofit2

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

自定义 SharedPreferences 类

我是 android 新手和学习者。我的应用程序中有主题更改选项,用户可以在其中切换主题。我使用全局变量在应用程序中保存主题编号,但当应用程序从后台清除时,它会出现损失。所以我考虑使用 SharedPreferences 来达到这个目的。我找到了一种从这里存储和检索 SharedPreference 的简单方法。

我的代码如下

public class Keystore {
    private static Keystore store;
    private SharedPreferences SP;
    private static String filename="Keys";
    public static int theme=1;

    private Keystore(Context context) {
        SP = context.getApplicationContext().getSharedPreferences(filename,0);
    }

    public static Keystore getInstance(Context context) {
        if (store == null) {
            store = new Keystore(context);
        }
        return store;
    }

    public void put(String key, String value) {
        SharedPreferences.Editor editor;
        editor = SP.edit();
        editor.putString(key, value);
        editor.apply();
    }

    public String get(String key) {
        return SP.getString(key, …
Run Code Online (Sandbox Code Playgroud)

java android sharedpreferences

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

视图适配器警告中的无条件布局膨胀

我在我的警报对话框中使用 GridView 和下面的代码。它给了我标题中调用的错误。我的代码和更多必需的信息如下所示。

  private void showGotoPageDialog() {

        final Dialog mDialog = new Dialog(getActivity());
        mDialog.setContentView(R.layout.grid_dialogue);
        mDialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        GridView mGridView = (GridView) mDialog.findViewById(R.id.grid_dialog);
        ArrayList<String> tmp = new ArrayList<>(mPageOptions.length);
        for(int i = 0; i < mPageOptions.length; i++)
        {
            tmp.add(mPageOptions[i].split(" ")[1]);
        }
        CustomAdapter adapter = new CustomAdapter(getActivity(), tmp, mPageIndx);
        //ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, tmp);
        mGridView.setAdapter(adapter);
        mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
                mDialog.dismiss();
                mPageIndx = item + 1;
                updateQuotesListServer();
                updatePageInfo();
            }
        });
        mDialog.show();
        TextView …
Run Code Online (Sandbox Code Playgroud)

java android android-layout

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