如何在android中像没有微调器的微调器一样弹出列表?

How to popup list like a spinner without spinner in android?(如何在android中像没有微调器的微调器一样弹出列表?)
本文介绍了如何在android中像没有微调器的微调器一样弹出列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的活动中有一个微调器小部件,可让用户选择列表名称.

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中像没有微调器的微调器一样弹出列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)