0

アプリ用の単純な日付と時刻のピッカーを作成しようとしています。XML ファイルは次のとおりです。

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TimePicker
            android:id="@+id/timePicker1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <DatePicker
            android:id="@+id/datePicker1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:spinnersShown="true"
             />
...Rest of the code

そして、これが私がそれを見る方法です:

ここに画像の説明を入力

だから私は2つの質問があります:

  1. AM/PM ボタンを表示せず、24 時間形式の時計だけを表示する可能性はありますか?
  2. カレンダーをそのように見るのはなぜですか? 日/月/年を正常に表示するにはどうすればよいですか?
4

1 に答える 1

1

解決策を見つけました:

tp = (TimePicker)findViewById(R.id.timePicker1);
tp.setIs24HourView(true);
dp = (DatePicker)findViewById(R.id.datePicker1);
dp.setCalendarViewShown(false);
于 2013-09-29T16:55:14.797 に答える