gpt4 book ai didi

android - 无法将 Android CalendarView 更改为另一个月份(Samsung S Duos - Android 4.2.2)

转载 作者:太空狗 更新时间:2023-10-29 13:13:14 24 4
gpt4 key购买 nike

Android 在 API 11 中引入了一个 CalendarView。我已经在我的应用程序中实现了它,它似乎工作正常,因为它显示了一个看起来非常正常的整月日历,而且我可以选择一个日期。它会触发适当的事件,我可以毫无问题地在我的代码中读取选定的日期。

screen shot of my CalendarView

但是我不能把它提前到当月!文档说

A user can select a date by taping on it and can scroll and fling the calendar to a desired date.

(“taping”出现在文档中;我认为这是“tapping”的拼写错误)

我试过轻扫、滑动、滚动,但没有任何反应。我需要做些什么才能启用此功能吗?

我的 XML 看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >

<!-- This linear layout is because the scrollview can have only 1 direct child -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >

<!-- Relative layout for Workorder -->
<RelativeLayout
android:id="@+id/rellayWorkorder"
android:background="#383838"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="2dp">
<TextView
android:id="@+id/workorderlabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="2dp"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Work Order:"/>

<TextView
android:id="@+id/workorderContent"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="2dp"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="---workorder---"/>
</RelativeLayout>


<!-- Relative layout for Required Time
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"></FrameLayout> -->

<RelativeLayout
android:id="@+id/rellayRequiredTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="2dp">
<TextView
android:id="@+id/requiredTimelabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="2dp"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Required Time:"/>

<TextView
android:id="@+id/requiredTimeContent"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="2dp"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="--- 00 minutes ---"/>
</RelativeLayout>

<!-- Relative layout for Time remaining -->
<RelativeLayout
android:id="@+id/rellayTimeRemaining"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="2dp">
<TextView
android:id="@+id/timeremaininglabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="2dp"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Time Remaining:"/>

<TextView
android:id="@+id/tviewtimeremainingContent"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="2dp"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="--- 0:00:00---"/>
</RelativeLayout>

<!-- Linear layout for Record Start / Record End buttons -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" >
<Button
android:id="@+id/debulkrecordStart"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginRight="4dp"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:onClick="OnSetRecordStartTimeClick"
android:text="Record Start"/>
<Button
android:id="@+id/debulkrecordEnd"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginRight="4dp"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:onClick="OnSetRecordEndTimeClick"
android:text="Record End"/>
</LinearLayout>

<!-- Relative layout for Vacuum level -->
<RelativeLayout
android:id="@+id/rellayvacuumlevel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp">
<TextView
android:id="@+id/vaclabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="2dp"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Vacuum Level (inches Hg):"/>
<EditText
android:id="@+id/vacleveledit"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_alignParentRight = "true"
android:layout_margin="2dp"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall"
android:inputType="text|textCapCharacters"
android:text="vac level"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"/>
</RelativeLayout>

<!-- Relative layout for Vac Gauge Equipment # -->
<RelativeLayout
android:id="@+id/rlayvacuumGauge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp">
<TextView
android:id="@+id/vacgaugelabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="2dp"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Vac Gauge Equipment #:"/>
<EditText
android:id="@+id/vacgaugeedit"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_alignParentRight = "true"
android:layout_margin="2dp"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall"
android:inputType="text|textCapCharacters"
android:text="equip. #"/>
</RelativeLayout>



<!-- Relative layout for Calibration Due date -->
<RelativeLayout
android:id="@+id/rlaycalibdue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp">
<TextView
android:id="@+id/calibduelabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="2dp"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Calibration Due Date:"/>
<EditText
android:id="@+id/calibdueedit"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_alignParentRight = "true"
android:layout_margin="2dp"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall"
android:inputType="text|textCapCharacters"
android:text="mm/dd/yyyy"/>
</RelativeLayout>


<CalendarView
android:id="@+id/debulkcalendar"
android:layout_width="match_parent"
android:layout_height="240dp"
android:minDate="01/01/2016"
android:maxDate="11/30/2016"
/>


<!-- this linear layout is for the debulk override and done buttons -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" >
<Button
android:id="@+id/debulkOverride"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginRight="4dp"
android:onClick="OnResetClick"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Override"/>
<Button
android:id="@+id/debulkDone"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginRight="2dp"
android:onClick="onDoneBtnClick"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Done"/>
</LinearLayout>

</LinearLayout>

</ScrollView>

编辑:
抱歉,XML 太长了 - 在我最初的帖子中,我只有 CalendarView,但有人请求了整个 XML。

同时为了排除它可能是我在我的三星 S5 (Android 5.0) 上测试过的设备所独有的可能性,并得到了相同的结果。

最佳答案

根据我的假设,它不会仅仅因为可滚动的父级而滚动或快速移动,您可以在没有 ScrollView 的情况下检查它吗?

因为我测试过

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CalendarView
android:id="@+id/debulkcalendar"
android:layout_width="match_parent"
android:layout_height="240dp"
android:minDate="01/01/2016"
android:maxDate="11/30/2016"/>
</LinearLayout>

及其完美的工作

你可以使用NestedScrollView

NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.

关于android - 无法将 Android CalendarView 更改为另一个月份(Samsung S Duos - Android 4.2.2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37735266/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com