【问题标题】:Spinner showing items as Drop Down List微调器将项目显示为下拉列表
【发布时间】:2019-08-29 09:34:09
【问题描述】:

我在选项卡布局内调用的活动中制作了一个微调器。
问题是项目(3 个)正在单独的对话框中显示,就像下拉列表一样,而不是作为旋转器。

我遵循this 的例子。如图所示我期待的图片

但我得到了这个:

& 这个
.

我只想在微调器中显示 3 个项目,并且不希望在新对话框中选择这些项目。我已经在 2.3.3 和 4.0.3 模拟器上尝试了我的代码。

有什么建议吗?
谢谢

【问题讨论】:

  • 您的 targetSDK 应设置为更高的 API 级别,可能是最新的 16 或 17,无论您拥有但高于 12,以便微调器显示为下拉列表而不是选择对话框。

标签: android android-layout spinner android-spinner


【解决方案1】:

作为下拉菜单的微调器是 HOLO 主题。第一张图片是 HOLO 主题,第二张和第三张不是。从 api 级别 11 开始支持 Holo 主题..

如果你想应用 Holo 主题。设置

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" />

以及 values-v11 文件夹中的 styles.XML

<resources>

<!--
    Base application theme for API 11+. This theme completely replaces
    AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
    <!-- API 11 theme customizations can go here. -->
</style>

styles.XMLvalues 文件夹中

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light.NoTitleBar">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>


 <style name="progressbar_holo" parent="@android:style/Theme.Light">
</style>

AndroidMeanifeast.xml

android:theme="@style/AppTheme"

应用程序标签中。

按照这2个链接 1.https://github.com/ChristopheVersieux/HoloEverywhere
2.https://github.com/ChristopheVersieux/HoloEverywhere

【讨论】:

  • 感谢您的回复。我当前的目标 SDK 为 10,更高的 SDK 为 15,最小值为 8。但如果我将目标 SDK 更改为较新版本,则在模拟器中的 2.3.3(即 SDK 版本 10)上看起来不一样。有什么方法可以在我的应用程序中绑定HOLO 主题?这样如果用户在 2.3.3 平台上打开它,他会体验到完全相同的 UI 吗?
  • 是的.. 可悲的是,除了提高我的目标 SDK 版本之外别无他法。将您的标记为答案。谢谢:D
  • 并支持我的答案.. 以便其他人可以使用此信息:-D
  • 查看我编辑的答案....我发现这也适用于 2.2 和 2.3 中的 HOLO 主题..
  • 再次感谢!好吧,我现在不想包含任何外部库(上面的链接示例使用 2)(除非非常需要)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多