Code example for PreferenceScreen

Methods: addPreference

0
        String packageName = summary;
        pref.setKey(packageName);
        pref.setTitle(title);
        pref.setSummary(packageName);
        if(icon != null) pref.setIcon(icon);
        mPreferenceScreen.addPreference(pref);
    } 
 
    private Drawable getApplicationIcon(String packageName) {
        try { 
            Drawable icon = mPackageManager.getApplicationIcon(packageName);
            return icon;
        } catch(NameNotFoundException e) {
            return null; 
        } 
    } 
 
    private Drawable getDrawable(String drawableName){
        int resourceId = Resources.getSystem().getIdentifier(drawableName, "drawable", "android");
        if(resourceId == 0) {
Stop searching for code, let great code find you!  Add Codota to your java IDE