android的自定义对话框 android对话框自定义日期 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 AlerDialog dialog;Builder builder=new Alert.Builder(this);builder.setView();dailog=builder. 1.布局 < LinearLayout android:id ="@+id/collection_overpass_patrolinfo_linearlayout_XCSJ" android:layout_width ="wrap_content" android:layout_height ="wrap_content" tools:ignore ="UseCompoundDrawables" > < TextView android:id ="@+id/collection_overpass_patrolinfo_XCSJ" style= "@style/common_style" android:layout_width ="wrap_content" android:layout_height ="wrap_content" android:hint ="@string/collection_patrolinfo_chose_time" > </ TextView> < ImageView android:id="@+id/collection__picker_imageView" android:layout_width ="wrap_content" android:layout_height ="wrap_content" android:src ="@drawable/datepicker" tools:ignore ="ContentDescription" > </ ImageView> </ LinearLayout>2.点击linearlayout弹出日期对话框 private LinearLayout linearLayout_XCSJ; private TextView textView_XCSJ ; linearLayout_XCSJ = (LinearLayout) findViewById(R.id.collection_overpass_patrolinfo_linearlayout_XCSJ ); // 设置按钮的点击事件监听器 linearLayout_XCSJ .setOnClickListener( new mSJOnClickListener());// 获取一个日历对象 Calendar date = Calendar. getInstance(Locale. CHINA); // 当点击DatePickerDialog控件的设置按钮时,调用该方法 DatePickerDialog.OnDateSetListener d_xcsj = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { // 修改日历控件的年,月,日 // 这里的year,monthOfYear,dayOfMonth的值与DatePickerDialog控件设置的最 新值一致 date.set(Calendar. YEAR, year); date.set(Calendar. MONTH, monthOfYear); date.set(Calendar. DAY_OF_MONTH , dayOfMonth); // 将页面TextView的显示更新为最新时间 textView_XCSJ.setText(CommonUtils. getDate( date.getTime())); } }; private class mSJOnClickListener implements OnClickListener { @Override public void onClick(View v) { SimpleDateFormat fromat = new SimpleDateFormat( "yyyy-MM-dd" ); Date d = new Date(); date.setTime(d); DatePickerDialog.OnDateSetListener d_sj = null; if (v == linearLayout_XCSJ) d_sj = d_xcsj ; else d_sj = d_fxwtjtsj ; // 生成一个DatePickerDialog对象,并显示。显示的DatePickerDialog控件可以选择年月日,并设置 new DatePickerDialog(OverPass_PatrolInfoActivity. this, d_sj, date.get(Calendar. YEAR), date.get(Calendar. MONTH), date.get(Calendar. DAY_OF_MONTH )).show(); } }拿去用。 一个应用是否可以有2个入口activity? ANR的log如何分析才能快速找到问题的原因? 手机怎么连网 Android 编译framework下的systemUI android 如何获得默认接入点的_id 点击ImageView显示大图,在大图上点击一下,就关闭大图 大家帮帮忙,怎么监听ExpandableListView子元素的点击动作 求反编译工具 Gallery出现了异灵现像(求高手相助) 请问Android上有什么软件可以录制频幕操作的视频? 新手想学Android,求推荐本书 高效多产的java/android程序员是什么样的?
Builder builder=new Alert.Builder(this);
builder.setView();dailog=builder.
1.布局
< LinearLayout
android:id ="@+id/collection_overpass_patrolinfo_linearlayout_XCSJ"
android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
tools:ignore ="UseCompoundDrawables" > < TextView
android:id ="@+id/collection_overpass_patrolinfo_XCSJ"
style= "@style/common_style"
android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
android:hint ="@string/collection_patrolinfo_chose_time" >
</ TextView> < ImageView
android:id="@+id/collection__picker_imageView"
android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
android:src ="@drawable/datepicker"
tools:ignore ="ContentDescription" >
</ ImageView>
</ LinearLayout>
2.点击linearlayout弹出日期对话框
private LinearLayout linearLayout_XCSJ;
private TextView textView_XCSJ ;
linearLayout_XCSJ = (LinearLayout) findViewById(R.id.collection_overpass_patrolinfo_linearlayout_XCSJ ); // 设置按钮的点击事件监听器
linearLayout_XCSJ .setOnClickListener( new mSJOnClickListener());
// 获取一个日历对象
Calendar date = Calendar. getInstance(Locale. CHINA); // 当点击DatePickerDialog控件的设置按钮时,调用该方法
DatePickerDialog.OnDateSetListener d_xcsj = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// 修改日历控件的年,月,日
// 这里的year,monthOfYear,dayOfMonth的值与DatePickerDialog控件设置的最 新值一致
date.set(Calendar. YEAR, year);
date.set(Calendar. MONTH, monthOfYear);
date.set(Calendar. DAY_OF_MONTH , dayOfMonth);
// 将页面TextView的显示更新为最新时间 textView_XCSJ.setText(CommonUtils. getDate( date.getTime()));
}
}; private class mSJOnClickListener implements OnClickListener {
@Override
public void onClick(View v) {
SimpleDateFormat fromat = new SimpleDateFormat( "yyyy-MM-dd" );
Date d = new Date();
date.setTime(d); DatePickerDialog.OnDateSetListener d_sj = null;
if (v == linearLayout_XCSJ)
d_sj = d_xcsj ;
else
d_sj = d_fxwtjtsj ;
// 生成一个DatePickerDialog对象,并显示。显示的DatePickerDialog控件可以选择年月日,并设置
new DatePickerDialog(OverPass_PatrolInfoActivity. this, d_sj,
date.get(Calendar. YEAR), date.get(Calendar. MONTH),
date.get(Calendar. DAY_OF_MONTH )).show();
}
}拿去用。