0

I am trying to use a NumberPicker in a dialog.

When i add the NumberPicker to the view it looks like follows:

NumberPicker

My xml-file for the Dialog looks pretty simple like this:

<?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>

My code is simply:

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);

Manifest file:

<?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>

Styles xml file:

<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>

Adding android:theme="@android:style/Theme.Dialog" results in the following visual:

NumberPicker Theme

Does anyone have an idea why i can't use the MaterialDesign NumberPicker?

Styler2go
  • 604
  • 2
  • 12
  • 31

1 Answers1

0

It seems to be a problem with the Visual Studio Android Emulator using Hyper-V.

Problem did not appear when installing the App on my mobile phone or in Android SDK emulator using HAXM.

Styler2go
  • 604
  • 2
  • 12
  • 31
  • Visual Studio? Anyway, you can accept your answer so that no one else comes here looking for an unanswered question to answer. – Kamran Ahmed Oct 30 '16 at 04:51
  • @KamranAhmed had to wait 24 hours to accept the answer. Yes, The Visual Studio Android Emulator is using a Hyper-V machine which is incredible fast. Good replacement if you need Hyper-V for other VMs and can't use the Android SDK emulator. – Styler2go Oct 30 '16 at 07:55