我的活动中有一个微调器小部件,可让用户选择列表名称.
I have a spinner widget in my activity which lets users pick a list name.
通常,微调器的功能是在列表之间切换,但在某些情况下,我换掉了选择更改侦听器,以使用相同的选项列表执行不同的功能.一旦做出选择,旧的听众就会恢复,生活继续.
Normally, the function of the spinner is to switch between lists but for a couple of instances, I swap out the selection change listener to perform a different function with the same list of options. Once the selection has been made, the old listener is restored and life goes on.
这是一个糟糕且错误的安排.相反,我想要一个函数,它只接受一个选择侦听器和一些其他参数,并显示一个弹出列表,该列表由与微调器相同的光标(或相同的光标)填充,而不使用微调器本身.
This is a bad and buggy arrangement. Instead, I would like to have a function that just takes a selection listener and some other parameters and shows a popup list that's populated by the same cursor (or and identical cursor) as the spinner, without using the spinner itself.
有什么办法可以做到吗?
Is there any way I can do this?
使用 AlertDialog.Builder
并通过 setAdapter()
提供一个 Adapter
生成你的行.
Use AlertDialog.Builder
and supply an Adapter
via setAdapter()
that generates your rows.
在您的情况下,我不会使用相同的 Cursor
,因为 Cursor
具有当前行的固有概念,因此会弄乱 Cursor
当你的 SpinnerAdapter
使用它时,可能会搞砸 Spinner
.使用相同的 Cursor
.
In your case, I would not use the same Cursor
, as a Cursor
has an intrinsic notion of the current row, and so messing with the Cursor
while it is used by your SpinnerAdapter
could screw up the Spinner
. Go with an identical Cursor
.
这篇关于如何在android中像没有微调器的微调器一样弹出列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!