gpt4 book ai didi

android - android : arrows not showing 中的日期选择器

转载 作者:行者123 更新时间:2023-11-29 14:17:12 26 4
gpt4 key购买 nike

我遇到了 DatePicker 的问题:我在正常布局中使用它,而不是在 Fragment 或 Dialog 中。这是布局(我有两个,这是其中之一):

 <DatePicker
android:id="@+id/historic_fin_datepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/historic_separator2"
android:layout_centerInParent="true"
android:calendarViewShown="false" >

问题是在应用程序中,没有显示 DatePicker 的典型箭头

这些是我使用日期选择器的 Activity 的方法。

/* OWN METHODS */
private void initializeUIFields() {
seeHistoricButton = (RelativeLayout) findViewById(R.id.historic_see_layout);
seeHistoricButton.setOnClickListener(this);
datep_ini = (DatePicker) findViewById(R.id.historic_ini_datepicker);
datep_fin = (DatePicker) findViewById(R.id.historic_fin_datepicker);
setCurrentDate();

}

/** This method set the date of the both datepickers to the actual date */
public void setCurrentDate() {

final Calendar calendar = Calendar.getInstance();

int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);

// set current date into Date Picker
datep_ini.init(year, month, day, null);
datep_fin.init(year, month, day, null);

}
/* This manage the button, if it is clicked, this method gets the date of the datepicker and go to a new activity */
@Override
public void onClick(View v) {
int year, month, day;

year = datep_ini.getYear();
month = datep_ini.getMonth() + 1;
day = datep_ini.getDayOfMonth();
date_ini = day + "-" + month + "-" + year;

year = datep_fin.getYear();
month = datep_fin.getMonth() + 1;
day = datep_fin.getDayOfMonth();
date_fin = day + "-" + month + "-" + year;

goToHistoricDetailView();
}

我想知道这是否与不使用 Fragment 或 Dialog 有关。任何帮助都会很棒。

我为 Android 4.4.2 构建项目,并在装有 Android 4.4.2 的智能手机上测试它

完成的布局代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white" >

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/continue_button_height" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/field_margin_small"
android:layout_marginRight="@dimen/field_margin_small"
android:orientation="vertical" >

<!-- Stard Date Layout -->

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<LinearLayout
android:id="@+id/historic_ini_title"
android:layout_width="wrap_content"
android:layout_height="@dimen/field_title_area"
android:layout_alignLeft="@+id/historic_ini_datepicker"
android:layout_marginTop="@dimen/field_margin_small"
android:orientation="horizontal" >

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >

<ImageView
android:layout_width="@dimen/historic_calendar_size"
android:layout_height="@dimen/historic_calendar_size"
android:layout_centerVertical="true"
android:contentDescription="@string/historic_calendar_img"
android:src="@drawable/historic_date_icon" />
</RelativeLayout>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >

<TextView
android:id="@+id/historic_ini_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="sans-serif-bold"
android:text="@string/historic_ini_date"
android:textColor="@color/sky_blue"
android:textSize="@dimen/field_title" />
</RelativeLayout>
</LinearLayout>

<ImageView
android:id="@+id/historic_separator1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/historic_ini_title"
android:layout_marginBottom="@dimen/field_margin_small"
android:contentDescription="@string/separator_blue"
android:src="@drawable/horizontal_blue_separator" />

<DatePicker
android:id="@+id/historic_ini_datepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/historic_separator1"
android:layout_centerInParent="true"
android:calendarViewShown="false"
android:spinnersShown="true" >
</DatePicker>
</RelativeLayout>

<!-- End Date Layout -->

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<LinearLayout
android:id="@+id/historic_fin_title"
android:layout_width="wrap_content"
android:layout_height="@dimen/field_title_area"
android:layout_alignLeft="@+id/historic_fin_datepicker"
android:layout_marginTop="@dimen/field_margin_small"
android:orientation="horizontal" >

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >

<ImageView
android:layout_width="@dimen/historic_calendar_size"
android:layout_height="@dimen/historic_calendar_size"
android:layout_centerVertical="true"
android:contentDescription="@string/historic_calendar_img"
android:src="@drawable/historic_date_icon" />
</RelativeLayout>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >

<TextView
android:id="@+id/historic_fin_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="sans-serif-bold"
android:text="@string/historic_fin_date"
android:textColor="@color/sky_blue"
android:textSize="@dimen/field_title" />
</RelativeLayout>
</LinearLayout>

<ImageView
android:id="@+id/historic_separator2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/historic_fin_title"
android:layout_marginBottom="@dimen/field_margin_small"
android:contentDescription="@string/separator_blue"
android:src="@drawable/horizontal_blue_separator" />



<DatePicker
android:id="@+id/historic_fin_datepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/historic_separator2"
android:layout_centerInParent="true"
android:calendarViewShown="false" >
</DatePicker>
</RelativeLayout>
</LinearLayout>
</ScrollView>

<RelativeLayout
android:id="@+id/historic_see_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/continue_button_height"
android:layout_alignParentBottom="true"
android:background="@color/sky_blue"
android:clickable="true"
android:fontFamily="sans-serif-light" >

<TextView
android:id="@+id/historic_see"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:fontFamily="sans-serif"
android:text="@string/historic_see"
android:textColor="@color/white"
android:textSize="@dimen/continue_button_text" />
</RelativeLayout>

我试过使用 DialogFragment,就像在 Android Developers Guide 中一样,但即使有了它,我也看不到箭头。

最佳答案

试试这个

  <DatePicker
android:id="@+id/historic_fin_datepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/historic_separator2"
android:layout_centerHorizontal="true"
android:calendarViewShown="false" >

关于android - android : arrows not showing 中的日期选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24156970/

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