android 获取alertdialog的view,android – 如何在AlertDialog中显示CalendarView?

我正在尝试在警报对话框中显示CalendarView,但所有显示的都是月/年和星期几.

这些是布局文件的内容:

android:id="@+id/myLayout"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

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" />

这是我用于将布局添加到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",int whichButton) {

// Do nothing.

}

}

).show();

任何帮助都会非常感激,因为我完全被难倒了.该应用程序没有给我任何错误继续.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值