android – 如何在AlertDialog中显示CalendarView?

android – 如何在AlertDialog中显示CalendarView?,第1张

概述我正在尝试在警报对话框中显示CalendarView,但所有显示的都是月/年和星期几. 这些是布局文件的内容: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/myLayout" android:layout_width="match_parent" 我正在尝试在警报对话框中显示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",int whichbutton) {            // Do nothing.        }    }    ).show();

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

解决方法 要正确显示日历,需要最小高度.其余代码工作正常. 总结

以上是内存溢出为你收集整理的android – 如何在AlertDialog中显示CalendarView?全部内容,希望文章能够帮你解决android – 如何在AlertDialog中显示CalendarView?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1139133.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-31
下一篇2022-05-31

发表评论

登录后才能评论

评论列表(0条)

    保存