Android Spinner 和视图。填充数据时消失
我有两个旋转器,其中一个可能是可见的,另一个可能是不可见的,这取决于数据,它就像一棵树,但在旋转器中表示。
因此,我使用 setVisibility(view.GONE) 来隐藏其中之一,但我仍然需要用来自数据库的一些 ID 和值来填充它。它只是一个值,但我需要将其添加到微调器中,这是未来的要求。
那么我需要在微调器中获取该值吗? 我怎样才能访问它?
I have two spinners, one of them may be visible and the other may be invisible that depends on the data, it's like a tree but represented in a spinner.
So I use setVisibility(view.GONE)
to hide one of them, but I still need to fill it with some IDs and values that came from DB. It is only one value but I need to add it to the spinner, it is a future requirement.
So I need to get that value in the spinner?
How can i access it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就像不是“Visible.GONE”一样,视图仍然存在,但隐藏了。您可以通过编程方式访问它并初始化它
Just do it like if it wasn't "Visible.GONE", the View is still there, but hidden. You can access it and initialize it programatically
只要在需要用数据填充 Spinner 之前实例化它,可见性就没有任何关系。该实例已经在内存中,您仍然可以对其进行操作。
这样想:
你仍然拥有它
As long as the Spinner is instantiate before you need to fill it with data, there is nothing to with the visibility. That instance is already in the memory you still can do operation on it.
Think like this:
You still have it