76873

Using SimonVT number picker and unable to inflate xml

Question:

So I'm using <a href="https://github.com/SimonVT/android-numberpicker" rel="nofollow">SimonVT number picker</a> to try and create a number picker that works with gingerbread. Unfortunately when I try to set it up as a dialog, it crashes when it tries to inflate the xml. I honestly have spent a while on this and cannot for the love of me figure out. Can anyone else?

This is where it crashes:

import net.simonvt.numberpicker.NumberPicker; import android.app.AlertDialog; import android.app.Dialog; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.view.View; public class setSnoozeMethodDialog extends DialogFragment{ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.set_snooze_dialog, null); NumberPicker np = (NumberPicker) view.findViewById(R.id.numberPicker); np.setMaxValue(20); np.setMinValue(0); np.setFocusable(true); np.setFocusableInTouchMode(true); builder.setView(view); return builder.create(); }

This is the xml that is having trouble being inflated

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:gravity="center"> <net.simonvt.numberpicker.NumberPicker android:id="@+id/numberPicker" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>

This is the error

01-07 23:44:33.308: E/AndroidRuntime(623): FATAL EXCEPTION: main 01-07 23:44:33.308: E/AndroidRuntime(623): android.view.InflateException: Binary XML file line #8: Error inflating class net.simonvt.numberpicker.NumberPicker 01-07 23:44:33.308: E/AndroidRuntime(623): at android.view.LayoutInflater.createView(LayoutInflater.java:518) 01-07 23:44:33.308: E/AndroidRuntime(623): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570) 01-07 23:44:33.308: E/AndroidRuntime(623): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 01-07 23:44:33.308: E/AndroidRuntime(623): at android.view.LayoutInflater.inflate(LayoutInflater.java:408) 01-07 23:44:33.308: E/AndroidRuntime(623): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 01-07 23:44:33.308: E/AndroidRuntime(623): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)

I put these in my manifest already

<activity android:name="net.simonvt.numberpicker.samples.DarkThemeActivity" android:theme="@style/SampleTheme" /> <activity android:name="net.simonvt.numberpicker.samples.LightThemeActivity" android:theme="@style/SampleTheme.Light" />

This is in my theme.xml in value folder

<resources> <style name="SampleTheme" parent="android:Theme"> <item name="numberPickerStyle">@style/NPWidget.Holo.NumberPicker</item> </style> <style name="SampleTheme.Light" parent="android:Theme.Light"> <item name="numberPickerStyle">@style/NPWidget.Holo.Light.NumberPicker</item> </style>

Answer1:

Figured it out. I needed to add

<resources> <style name="SampleTheme" parent="android:Theme"> <item name="numberPickerStyle">@style/NPWidget.Holo.NumberPicker</item> </style> <style name="SampleTheme.Light" parent="android:Theme.Light"> <item name="numberPickerStyle">@style/NPWidget.Holo.Light.NumberPicker</item> </style>

to my styles file, not the theme file.

Recommend

  • Get file path from Uri from Video Chooser
  • Is it possible to set an Android Notification or a later date and time that will fire when the app i
  • How to use OnMarkerClickListener
  • Subviews for custom UIView with Nib (.xib) don't load?
  • Reading a file located in a jar as java.io.File object
  • Set text in TextView in custom dialog
  • Retrofit 2 error: NetworkOnMainThreadException
  • Facebook API: cannot login on Android
  • RxJava,Retrofit Error :Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
  • Store additional information during registration with Firebase in Android
  • How to add plugin dependencies to pom.xml
  • How to use getFilter form Listadapter
  • How to add an item to a ListView with each Button click
  • Where are files stored on an Android emulator?
  • Can I customize a Jackson ObjectMapper by adding a module?
  • Back press fragments issue in android
  • Trying to get all column names in a table
  • Background not visible in surface view
  • android-How to enable cache or buffering when videoView have downloaded a video
  • Visual Studio 2008 and JavaScript brackets formatting
  • Unable to use dot layout (graphviz as a library)
  • OnItemSelectedListener for Spinner that was added programmatically does not trigger
  • Listview - list item selection and initial setting (custom made items)
  • How to set the navigation bar to the top in Table View?
  • UIPickerView without IB?
  • How do i disable a text box within an iframe
  • I have two activity.I want to Send the data from second activity to previous activity.First activity
  • Cassandra NoClassDefFoundError: com/google/common/util/concurrent/AsyncFunction
  • Custom WebViewPage inject code when razor template is rendering
  • Unable to resolve Static method?
  • Replace Fragment with another on back button
  • Activity overlaying. WindowManager.LayoutParams
  • SqlCommand back up Database
  • How to get listview position?
  • Syntax error on tokens, AnnotationName expected instead - error on query
  • WPF version of .ScaleControl?
  • Android Activity.onWindowFocusChanged doesn't get called from within TabHost
  • align graphs with different xlab
  • How to stop GridView from loading again when I press back button?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize