8

私は、警告ダイアログにCalendarViewを表示しようとしていますが、表示されるのは月/年と曜日です。 これらは、レイアウトファイルの内容は以下のとおりです。AlertDialogにCalendarViewを表示するにはどうすればよいですか?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/myLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 
<CalendarView 
    android:id="@+id/calendarID" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:contentDescription="@string/cal_desc" 
    android:maxDate="01/01/2013" 
    android:minDate="09/01/2012" 
    android:showWeekNumber="false" 
    android:tag="my tag" /> 
</LinearLayout> 

これは私がAlertDialogにレイアウトを追加するために使用されるコードです:

LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService 
       (Context.LAYOUT_INFLATER_SERVICE); 
LinearLayout ll= (LinearLayout)inflater.inflate(R.layout.myLayout, null, false); 
CalendarView cv = (CalendarView) ll.getChildAt(0); 
cv.setOnDateChangeListener(new OnDateChangeListener() { 

     @Override 
     public void onSelectedDayChange(CalendarView view, int year, int month, 
       int dayOfMonth) { 
      // TODO Auto-generated method stub 
      initScheduleEvent(); 
     } 
    }); 
new AlertDialog.Builder(MomAppActivity.this) 
    .setTitle("Event Calendar") 
    .setMessage("Click to schedule or view events.") 
    .setView(ll) 
    .setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
     public void onClick(DialogInterface dialog, int whichButton) { 
      //do nothing...yet 
     } 
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
     public void onClick(DialogInterface dialog, int whichButton) { 
      // Do nothing. 
     } 
    } 
    ).show(); 

私は完全に困惑していて、任意の助けを大幅に見ていただければ幸いです。アプリケーションは私に何かエラーを与えているわけではありません。

答えて

6

あなたの答えを見つけることを願ってみてください適切に表示されます。残りのコードは正常に動作しました。

+0

を試してみて、私は私のために働いhttp://stackoverflow.com/a/7033869/94148 – aleung

0

ダイアログのカスタマイズされたデザインが必要な場合は、レイアウトとウィジェットの要素を含むダイアログウィンドウの独自のレイアウトを作成できます。

は、これらのリンクは、あなたが最小の高さは、カレンダーのために必要とされた

  1. http://www.mkyong.com/android/android-custom-dialog-example/

  2. http://developer.android.com/guide/topics/ui/dialogs.html

  3. http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application

関連する問題