Android的微调有不同的布局和QUOT;下拉状态"和"关闭状态"? [英] Android Spinner with different layouts for "drop down state" and "closed state"?

查看:158
本文介绍了Android的微调有不同的布局和QUOT;下拉状态"和"关闭状态"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android微调鉴于我的布局。我想了微调,只显示一个文本项目时关闭,但是当用户点击就可以了(即打开微调对话框)我想告诉每个项目的更详细的信息,包括一个图标和一个额外的描述文本视图。因为它现在是微调显示了在两种状态下的非常相同的布局(图标,标题+说明)。

I have an Android Spinner view in my layout. I would like that spinner to show only a single text item when closed, but when the user clicks on it (i.e. opens the spinner dialog) I would like to show more extensive information for each item, including an icon and an additional description text view. As it is now the spinner shows the very same layout (icon, title + description) in both states.

如果我附上一个ArrayAdapter的微调,那么我可以访问一种叫setDropDownViewResource但是这并不一定就是我所需要的,因为我的飞旋的数据是从游标读取不是从任何种类的阵列(我有,截至目前,创建了自己的适配器,扩展BaseAdapter)。

If I attach an ArrayAdapter to the spinner, then I get access to something called "setDropDownViewResource" but that's not necessarily what I need, since my spinner data is fetched from a Cursor not from an Array of any kind (I have, as of now, created my own adapter, extending BaseAdapter).

任何人谁可以帮我吗?

推荐答案

您必须创建一个自定义的 适配器 类的微调,并覆盖两个方法<一href="http://developer.android.com/reference/android/widget/Adapter.html#getView%28int,%20android.view.View,%20android.view.ViewGroup%29"><$c$c>getView()对于常闭观和<一href="http://developer.android.com/reference/android/widget/SpinnerAdapter.html#getDropDownView%28int,%20android.view.View,%20android.view.ViewGroup%29"><$c$c>getDropDownView()在下拉列表视图。这两种方法都必须返回一个查看对象的单个元素。

You have to create a custom Adapter class for the Spinner and overwrite the two methods getView() for the normal closed view and getDropDownView() for the drop down list view. Both methods must return a View object for a single element.

看一看本教程它可以帮助你开始。

Have a look at this tutorial it might help you getting started.

这篇关于Android的微调有不同的布局和QUOT;下拉状态&QUOT;和&QUOT;关闭状态&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆