开发者

Is it possible to use an expandablelistview as a dropdownview for a spinner?

开发者 https://www.devze.com 2023-01-18 16:25 出处:网络
I have a 2d array of strings. I would like to use a spinner to allow users to select values from开发者_运维百科 the 2nd lvl of the array but I would like to display the selection options in a expandab

I have a 2d array of strings. I would like to use a spinner to allow users to select values from开发者_运维百科 the 2nd lvl of the array but I would like to display the selection options in a expandablelistview using the values of the 1st lvl of the array as category headers.

Is this possible, can someone point me in the right direction of how this should be implemented ?


You cannot directly use an ExpandableListView for the Spinner popup, any more than you can directly use a ListView for the Spinner popup. It is what it is, and that is defined by the Spinner class.

Options include:

  • Subclassing Spinner and overriding whatever drives the popup dialog
  • Copying Spinner into your project and replacing whatever drives the popup dialog (if overriding will not work due to method visibility, etc.)
  • Don't use a Spinner, and instead use a Button plus an AlertDialog containing an ExpandableListView, or something like that

In principle, you could override getDropDownView() in your SpinnerAdapter (e.g., ArrayAdapter). However, there is no concept of the drop-down view being disabled, and I assume you would want your category headers to be non-selectable. If, however, selecting a category is acceptable, this approach would be simplest.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号