小编Ast*_*hme的帖子

如何在偏好片段中改变文本样式

我已经创建了带有文本视图的首选项屏幕.用户可以在首选项屏幕中更改文本视图样式,如字体,颜色,大小.因此它将显示在我在偏好屏幕中创建的Textview上.但它不起作用.如果它的首选项活动,我们可以使用setContentview,在片段中我不知道如何传递视图..

 public final class TestFragment2 extends PreferenceFragment {
static TextView textView;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.preferences);
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View view = inflater.inflate(R.layout.customprefernce, null);
    textView = (TextView) view.findViewById(R.id.TextViewSample);

    final CheckBoxPreference checkboxPref = (CheckBoxPreference) getPreferenceManager()
            .findPreference("bold");

    checkboxPref
            .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
                public boolean onPreferenceChange(Preference preference,
                        Object newValue) {
                    // Log.d("MyApp", "Pref " + preference.getKey() +
                    // " changed to " + newValue.toString());
                    textView.setTextColor(Color.BLUE);
                    // Color is not changing.

                    return true;
                }
            });

}
Run Code Online (Sandbox Code Playgroud)

我有更改颜色的复选框,但它没有改变颜色textView.setTextColor(Color.BLUE);

Preferncescreen.xml

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen …
Run Code Online (Sandbox Code Playgroud)

xml android android-preferences android-layout android-fragments

8
推荐指数
0
解决办法
3574
查看次数

java.lang.UnsatisfiedLinkError - android studio gradle中的NDK?

文件夹结构

 app 
---main
    ---java
    ----jni
          -----Android.mk
          -----Application.mk
          ----- hello-jni.c
    ---res
Run Code Online (Sandbox Code Playgroud)

在build.gradle中

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.example.hellojni"
    minSdkVersion 17
    targetSdkVersion 21
    sourceSets.main {
        jni.srcDirs = []
        jniLibs.srcDir 'src/main/libs'

    }

    ndk {
        moduleName "hello-jni"
        cFlags "-std=c++11 -fexceptions"
        ldLibs "log"
        stl "gnustl_shared"
        abiFilter "armeabi-v7a"
    }

    task nativeLibsToJar(type: Zip, description: 'create a jar archive of the native libs') {
        destinationDir file("$buildDir/native-libs")
        baseName 'native-libs'
        extension 'jar'
        from fileTree(dir: 'libs', include: '**/*.so')
        into 'lib/'
    }

    tasks.withType(JavaCompile) {
        compileTask …
Run Code Online (Sandbox Code Playgroud)

java android gradle android-ndk android-studio

7
推荐指数
1
解决办法
4421
查看次数

设置上下文操作栏的样式?

我在操作栏中使用橙色主题,在用户尝试复制时编辑文本,粘贴它调用默认蓝色背景的上下文操作,这对用户来说有点奇怪,我可以更改上下文操作栏的背景吗?

android android-actionbar contextual-action-bar

6
推荐指数
1
解决办法
2273
查看次数

使用改造来隐藏json阵列?

这是我的Json

[  
{  
  "nata_center":{  
     "id":67,
     "nata_center_name":"Primo Institute of Design"
  }
 },
{  
  "nata_center":{  
     "id":68,
     "nata_center_name":"Sai Ganesh Institute"
  }
 }
]
Run Code Online (Sandbox Code Playgroud)

Pojo课程

public class Explorer {
    NataCenter nataCenter;

    public NataCenter getNataCenter() {
        return nataCenter;
    }

    public void setNataCenter(NataCenter nataCenter) {
        this.nataCenter = nataCenter;
    }
}
Run Code Online (Sandbox Code Playgroud)

2)

public class NataCenter {
    public String id;
    public String nata_center_name;

     public NataCenter(String id,String nata_center_name)
     {
      this.id=id;
     this.nata_center_name=nata_center_name;
     }

    public void setId(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public …
Run Code Online (Sandbox Code Playgroud)

java android json gson retrofit

6
推荐指数
1
解决办法
5646
查看次数

如何从毕加索的缓存中检索图像?

我正在使用picasso库来加载图像.在默认的毕加索中,它使用内部缓存来加载图像.但是根据我的app配置,我必须使用外部缓存(Cache on Disk).所以我将此代码用于磁盘上的缓存

              File httpCacheDir = new File(getApplicationContext().getExternalCacheDir(),"http");
                long httpCacheSize = 10 * 1024 * 1024; // 10 MiB
               HttpResponseCache.install(httpCacheDir, httpCacheSize);}
Run Code Online (Sandbox Code Playgroud)

毕加索很灵活.所以现在它在外部Sd卡中缓存图像..

缓存存储在sdcard/android/data/packagename/cache/http中.缓存存储在".1",".0"中.格式所以我只是打开它们并更改为".1"到".jpg".它给出了我需要的精确图像.但是如何以编程方式完成?但毕加索本身将我的记忆缓存到我的应用程序中以将图像加载到imageview中.但我必须将它们直接保存为sdcard作为图像/将位图设置为离线模式下的壁纸?

storage android caching http picasso

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

偏好活动与PreferenceFragment?

在偏好活动,我们可以使用这两种方法SetContentView(R.layout.main) ,并addXmlFromResources(R.xml.Preferences)用于定制个人偏好屏幕。例如,请参见此 在“偏好设置”屏幕上添加按钮

在PreferenceFragment中有可能吗?

在PreferenceFragment中,我添加addPreferencesFromResource(R.xml.PreferenceScreen);了onCreate方法。当我使用onCreateView时,强制关闭。我也尝试过布局充气机。没用

那么这仅在首选项Activity上可行吗?不是首选项片段?

PS-我正在使用支持V 13库。因此,我在“片段寻呼机适配器”中创建了“首选项片段”。请不要建议我为首选项片段创建首选项活动

xml android preferences android-layout

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

活动中的访问片段?

我有 2 个片段的一项主要活动。两个片段都有一个ListView. 我想更新MainActivity. 有没有办法在活动中访问片段列表适配器,而无需将适配器设为静态适配器。目前我正在这样做Mainactivity.java

public void updatelist() {
  if(fragmentstate=0)
    Fragment1.adapter.notifyDataSetChanged();
  else
    Fragment2.adapter.notifyDataSetChanged();

}
Run Code Online (Sandbox Code Playgroud)

android android-listview android-fragments

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