本文介绍了微调节目,如对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的微调,它就像打开一个对话框。我需要微调器来打开像下拉菜单。

I am using the spinner and it opens like a dialog. I need spinner to be open like dropdown menu.

下面是XML文件

 <Spinner
 android:id="@+id/sp_countrycode_issue_coupon"
 android:layout_width="60dp"
 android:layout_height="40dp"
 android:layout_gravity="center"
 android:layout_marginLeft="3dp"
 android:layout_weight="1"
 android:background="@drawable/img_small_box_green"
 android:dropDownSelector="@drawable/img_small_box_green"
 android:gravity="right|center"
 android:textAlignment="center" />

下面是code

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this, R.array.country_code,
            android.R.layout.simple_spinner_item);

adapter.setDropDownViewResource(R.layout.spinner_textview);
sp_country_code.setAdapter(adapter);

我贴我的图片波纹管像我的观点和微调显示视图。但我需要微调是显示器与第三图像

I posted my images bellow like my view and spinner display view. But I need the spinner to be display like the third image

推荐答案

对于在图片显示3 是适用于从版本3.0及以上信息下拉微调。对于previous版本例如 2.2和2.3将打开对话框一样。它会自动显示在下拉列表版本2.3以上

For the information Dropdown spinner that you shown in Image 3 is applicable from version 3.0 and above. For previous versions like 2.2 and 2.3 it will open like dialog. It will automatically show dropdown in versions above 2.3

样式会,如果你选择的Andr​​oid版本4.0或以上的自动添加。

Styles will be automatically added if you choose android version 4.0 or above.

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

Refrence code

Refrence code

    severitySpinner = (Spinner) findViewById(R.id.spinnerSeverity);
    severityAdapter = ArrayAdapter.createFromResource(this,
            R.array.severity_arrays, android.R.layout.simple_spinner_item);
    severityAdapter
            .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    severitySpinner.setAdapter(severityAdapter);

修改

<application
        android:icon="@drawable/appicon"
        android:label="Test"
        android:theme="@style/AppTheme" >

这篇关于微调节目,如对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:02