Search in sources :

Example 1 with IconListPreference

use of com.android.camera.IconListPreference in project android_packages_apps_Camera by CyanogenMod.

the class ListPrefSettingPopup method initialize.

public void initialize(ListPreference preference) {
    mPreference = preference;
    Context context = getContext();
    CharSequence[] entries = mPreference.getEntries();
    int[] iconIds = null;
    if (preference instanceof IconListPreference) {
        iconIds = ((IconListPreference) mPreference).getImageIds();
        if (iconIds == null) {
            iconIds = ((IconListPreference) mPreference).getLargeIconIds();
        }
    }
    // Set title.
    mTitle.setText(mPreference.getTitle());
    // Prepare the ListView.
    ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
    for (int i = 0; i < entries.length; ++i) {
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("text", entries[i].toString());
        if (iconIds != null)
            map.put("image", iconIds[i]);
        listItem.add(map);
    }
    SimpleAdapter listItemAdapter = new ListPrefSettingAdapter(context, listItem, R.layout.setting_item, new String[] { "text", "image" }, new int[] { R.id.text, R.id.image });
    ((ListView) mSettingList).setAdapter(listItemAdapter);
    ((ListView) mSettingList).setOnItemClickListener(this);
    reloadPreference();
}
Also used : Context(android.content.Context) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SimpleAdapter(android.widget.SimpleAdapter) IconListPreference(com.android.camera.IconListPreference) ListView(android.widget.ListView)

Aggregations

Context (android.content.Context)1 ListView (android.widget.ListView)1 SimpleAdapter (android.widget.SimpleAdapter)1 IconListPreference (com.android.camera.IconListPreference)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1