【问题标题】:Titanium Android : calendarViewShown not working Android 5.x and laterTitanium Android:calendarViewShown 不工作 Android 5.x 及更高版本
【发布时间】:2017-02-07 11:34:49
【问题描述】:

我一直在尝试使用 Android 中的日期选择器,它工作得很好,我的问题是 calendarViewShown 属性。我需要在所有版本的 android 中使用旧样式的日期选择器,这在 android 4 及更低版本中作为默认设置工作,但是当我们在 android 5 及更高版本上运行应用程序时,默认日期选择器显示日历,而不是我想要使用旧日期选择器。 为此,我使用了 calendarViewShown 属性,如下图所示,我没有得到预期的结果。

<Alloy>
<Window class="container">
<View backgroundColor="black" height="Ti.UI.SIZE" width="Ti.UI.SIZE">
<Picker calendarViewShown="false" nativeSpinner="true" type="Ti.UI.PICKER_TYPE_DATE" datePickerMode="spinner"></Picker>
</View>
</Window>
</Alloy>

【问题讨论】:

    标签: android android-5.0-lollipop appcelerator-titanium android-calendar android-datepicker


    【解决方案1】:

    我终于找到了解决这个问题的方法,我们必须将主题与选择器一起使用才能使用默认日期选择器。看看下面的代码:

    **** xml代码 ****

    <Alloy>
        <Window id="win" title="" backgroundColor="transparent">
            <View height="100%" width="100%" backgroundColor="transparent" id="backView"></View>
            <View height="Ti.UI.SIZE" layout="vertical" backgroundColor="#f2f2f2" width="90%">
                <Label id="currentDate" top="10" color="#000" bottom="10" left="20"></Label>
                <View height="1" left="0" right="0" backgroundColor="#d9d9d9"></View>
                <View id="pickerView" height="Ti.UI.SIZE"></View>
                <Picker calendarViewShown="false" nativeSpinner="true" type="Ti.UI.PICKER_TYPE_DATE" backgroundColor="#f2f2f2" id="androidPicker" width="Ti.UI.FILL"></Picker>
                <View height="1" left="0" right="0" backgroundColor="#d9d9d9"></View>
                <View height="40dp">
                    <View height="40dp" width="50%">
                    <Label id="cancelButton" color="#000" right="20dp" onClick="closeWindow">Cancel</Label>
                    </View>
                    <View height="40dp" width="50%">
                        <Label id="doneButton" color="#000" onClick="getDatePicker">Done</Label>
                    </View>
                </View>
            </View>
        </Window>
    </Alloy>
    

    在 platfrom >> custometheme.xml 的主题文件中粘贴以下样式

    **** 主题 ****

    <style name="Theme.Transparent" parent="@android:style/Theme.Holo.Light.Dialog">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:backgroundDimEnabled">true</item>
    </style>
    

    希望它也适用于其他人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-09
      • 1970-01-01
      • 2022-06-18
      • 1970-01-01
      • 2015-05-10
      相关资源
      最近更新 更多