preferencefragment - Increasing Items in a list view based on condition -
i want add listprefernce initailly ex:a,depending on condition same list want add other ex:b, how can achieve using list preferences .
i able add listview, listview rather list adding more entries...
here code: preferences.xml:
<preferencecategory android:key="custom_frag" android:title="some options"> addpreferencesfromresource(r.xml.preferences); preferencecategory targetcategory = (preferencecategory) findpreference("custom_frag"); listpreference checkboxpref1 = new listpreference(context); charsequence[] entries1 = { "googlemaps"}; charsequence[] entryvalues = { "1" }; checkboxpref1.setentries(entries1); checkboxpref1.setentryvalues(entryvalues); checkboxpref1.settitle("number of blahs"); targetcategory.addpreference(checkboxpref1); targetcategory.addpreference(checkboxpref1); final listpreference lp = setlistpreferencedata((listpreference) findpreference(custom_frag), getactivity()); preference.onpreferenceclicklistener() { sethasoptionsmenu(true); targetcategory.addpreference(lp); } private listpreference setlistpreferencedata(listpreference preference, activity activity) { charsequence[] entries = { "one", "two", "three" }; charsequence[] entryvalues = { "2", "3", "4" }; if(preference == null) preference = new listpreference(activity); preference.setentries(entries); preference.setdefaultvalue("1"); preference.setentryvalues(entryvalues); // preference.setsummary(preference.getentry()); preference.setdialogtitle("number of blah objects"); preference.setkey(custom_frag); return preference; }
for checkboxes1 want add these preferences. able add, getting 2 listpreferences rather 1 adding.
Comments
Post a Comment