Ste*_*e77 8 android numberpicker
我已经在这几天了,而且我已经放弃了,所以任何帮助都非常感谢!
我一直在尝试在我的Android应用程序中实现simonVT数字选择器.对于android来说是全新的,所以包括库,引用这个库并获得编译的所有东西本身就是几天的任务.现在我终于编译了所有内容我在运行时遇到以下错误:
04-06 10:58:37.126: E/AndroidRuntime(14324): java.lang.RuntimeException:
Unable to start activity ComponentInfo{com.example.goalminder/com.example.goalminder.AddGoal}:
android.view.InflateException: Binary XML file line #81:
Error inflating class net.simonvt.numberpicker.NumberPicker
Run Code Online (Sandbox Code Playgroud)
这是我的布局的开头:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/net.simonvt.numberpicker"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Run Code Online (Sandbox Code Playgroud)
注意 - 上面的'xmlns:app'部分有一个黄色警告标记 - 它没有被使用.我包含了另一个stackoverflow的答案.类似的问题.留下来劝阻这个建议.
这是numberpicker的xml:
<net.simonvt.numberpicker.NumberPicker
android:id="@+id/dayPicker"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="10dp"
android:layout_weight="1"/>
Run Code Online (Sandbox Code Playgroud)
我已经在我的主题文件中按照Simon的指示包含了主题.我不确定要给它的名字,所以我称它为'NumberPicker':
<resources>
<!-- Copy one of these attributes to your own theme (choose either dark or light).
<item name="numberPickerStyle">@style/NPWidget.Holo.NumberPicker</item>
<item name="numberPickerStyle">@style/NPWidget.Holo.Light.NumberPicker</item>
-->
<style name="NumberPicker" parent="android:Theme">
<item name="numberPickerStyle">@style/NPWidget.Holo.NumberPicker</item>
</style>
<style name="NumberPicker" parent="android:Theme.Light">
<item name="numberPickerStyle">@style/NPWidget.Holo.Light.NumberPicker</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
我还将以下内容添加到我的android清单中作为应用程序的子代:
<activity
android:name="net.simonvt.numberpicker.Numberpicker" />
<activity
android:name="net.simonvt.numberpicker.Scroller" />
Run Code Online (Sandbox Code Playgroud)
我已经遍布stackoverflow,所以我们上面所说的是散射枪的方法,我所看到的一切建议如此.如前所述,我正在挣扎于此,并接近实施一个标准的丑陋列表.
注意 - 我使用Numberpicker的原生android实现完成了所有这些工作.我想使用Simon VT的backport版本,因为我将支持API <11,其中包括Gingerbread,我认为它有39.7%的分布.如果您认为我不需要支持这一点,请告诉我.
小智 11
您需要在AndroidManifest.xml上为活动添加主题:示例:
<activity android:name="yourActivity" android:theme="@style/SampleTheme.Light"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4345 次 |
| 最近记录: |