首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NumberPicker没有主题

NumberPicker没有主题
EN

Stack Overflow用户
提问于 2016-10-28 07:05:04
回答 1查看 484关注 0票数 0

我试图在对话框中使用NumberPicker。

当我将NumberPicker添加到视图中时,如下所示:

我的对话框xml文件看起来非常简单,如下所示:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="wrap_content">


    <NumberPicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/numberPicker"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />
</RelativeLayout>

我的代码很简单:

代码语言:javascript
复制
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

LayoutInflater inflater = (LayoutInflater)builder.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout inflated = (RelativeLayout)inflater.inflate(R.layout.dialog_button_delay, (ViewGroup)getView());

final NumberPicker pick = (NumberPicker) inflated.findViewById(R.id.numberPicker);
String[] minuteValues = new String[37];

for (int i = 0; i < minuteValues.length; i++) {
    minuteValues[i] = String.valueOf(i*5);
}
pick.setWrapSelectorWheel(false);
pick.setMinValue(0);
pick.setMaxValue(36);
pick.setDisplayedValues(minuteValues);
builder.setView(inflated);

舱单档案:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="de.familyfood.familyfood">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar">
        <activity
            android:name=".MainActivity"
            android:label="@string/title_start">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".AddFoodActivity" />
        <activity
            android:name=".LoginActivity"
            android:label="@string/title_activity_login"/>
    </application>

</manifest>

样式xml文件:

代码语言:javascript
复制
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

</resources>

添加android:theme="@android:style/Theme.Dialog"会产生以下可视化结果:

有人知道为什么我不能使用MaterialDesign NumberPicker吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-29 09:48:33

使用Hyper-V的仿真程序似乎存在问题。

在我的手机或使用HAXM的Android模拟器上安装应用程序时,没有出现问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40299804

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档