相关疑难解决方法(0)

如何检测软件键盘在Android设备上是否可见?

Android中是否有办法检测屏幕上是否显示软件(又称"软")键盘?

keyboard android

221
推荐指数
15
解决办法
24万
查看次数

无法解析方法getActivity()

  • 我是Android的新手,并通过以下
    示例学习如何在Android中创建片段:片段导航抽屉

  • 在菜单项添加导航标题之间导航之间的代码包含一种方法getActivity().

  • 由于作者没有提到粘贴此代码的位置,我粘贴在我的MainActivity.java文件中

  • 菜单项之间的导航添加导航标题之间的代码是否由我粘贴在正确的位置?

  • 在方法中selectDrawerItem(MenuItem menuItem)有一个评论// Create a new fragment and specify the planet to show based on position
    作者希望我在这里添加一些东西.

  • 我在AndroidStudio上创建的项目文件布局如下:AndroidStudio Snapshot

android android-fragments navigation-drawer

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

getApplicationContext()和getActivity()之间的区别

是什么getApplicationContext()和getActivity()之间的区别在Android中?

android

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

Android - 在Fragment中使用SharedPrefs

我正在尝试使用共享首选项.

我已经创建了一个类 -

package com.bscheme.linkkin.utils;

import android.content.Context;
import android.content.SharedPreferences;
import com.bscheme.linkkin.R;

public class SharedDataSaveLoad {

    public static void save(Context context, String key, String value) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(context.getResources().getString(R.string.preference_file_key),Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.commit();
    }
    public static void save(Context context,String key, int value) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(context.getResources().getString(R.string.preference_file_key),Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putInt(key, value);
        editor.commit();
    }

    public static String  load(Context context, String key) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(context.getResources().getString(R.string.preference_file_key), Context.MODE_PRIVATE);
        return sharedPreferences.getString(key, "");
    }
    public static int loadInteger(Context context,String …
Run Code Online (Sandbox Code Playgroud)

android sharedpreferences android-fragments

-1
推荐指数
1
解决办法
325
查看次数