android - Different dropDownListViewStyles for different spinner styles -


in application theme have dropdownlistviewstyle , spinnerstyle whole application. in 1 fragment need spinner custom styled dropdownlistviewstyle (i need change divider). possible have spinner other dropdownlistviewstyle set in theme?

in spinner style or layout not possible set dropdown divider. not possible set dropdownlistviewstyle in spinner style or layout.

i stucked, hope have answer.

unfortunately, dropdownlistviewstyle hardcoded in spinner. if source, you'll find dropdownpopup class, extends listpopupwindow. in listpopupwindow class of interest dropdownlistview you'll find constructor:

public dropdownlistview(context context, boolean hijackfocus) {     super(context, null, com.android.internal.r.attr.dropdownlistviewstyle);     // ... } 

so way change theme, you've assessed. considering spinner in question being used in activity requires base theme, know of 1 workaround. unfortunately, way change theme of fragment. means all spinners in fragment have alternative theme. change theme of fragment @ runtime, in oncreateview this:

@override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         // create contextthemewrapper original activity context custom theme         context context = new contextthemewrapper(getactivity(), r.style.my_custom_theme);         // clone inflater using contextthemewrapper         layoutinflater localinflater = inflater.cloneincontext(context);         // inflate using cloned inflater, not passed in default          return localinflater.inflate(r.layout.my_layout, container, false);     } 

short of this, you're looking @ creating custom spinner, isn't too difficult, considering it's open source.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -