edit_text.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw v) { // Todo auto-generated method stub showPopup(MainActivity.this); } });
现在showPopup()方法:
// The method that displays the popup.private voID showPopup(Activity context) { // Inflate the popup_layout.xml LayoutInflater layoutInflater = (LayoutInflater)getBaseContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); layout = layoutInflater.inflate(R.layout.main3,null,false); // Creating the PopupWindow final PopupWindow popupWindow = new PopupWindow( layout,400,400); popupWindow.setContentVIEw(layout); popupWindow.setHeight(500); popupWindow.setoutsIDetouchable(false); // Clear the default translucent background popupWindow.setBackgroundDrawable(new BitmapDrawable()); CalendarVIEw cv = (CalendarVIEw) layout.findVIEwByID(R.ID.calendarVIEw); cv.setBackgroundcolor(color.BLUE); cv.setonDatechangelistener(new CalendarVIEw.OnDatechangelistener() { @OverrIDe public voID onSelectedDayChange(CalendarVIEw vIEw,int year,int month,int dayOfMonth) { // Todo auto-generated method stub popupWindow.dismiss(); Log.d("date selected","date selected " + year + " " + month + " " + dayOfMonth); } }); popupWindow.showAtLocation(layout,Gravity.top,5,170); }
现在,main3.xml文件:
<?xml version="1.0" enCoding="utf-8"?> <linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:ID="@+ID/layout" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical" > <CalendarVIEw androID:ID="@+ID/calendarVIEw" androID:layout_wIDth="match_parent" androID:layout_height="400dp" androID:clickable="true" androID:showWeekNumber="false" /> </linearLayout>
然后在快照下面看看你会自己定制这个d出窗口.
总结以上是内存溢出为你收集整理的Android:日历d出窗口中的日期选择器全部内容,希望文章能够帮你解决Android:日历d出窗口中的日期选择器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)