private void setEndTime(final TimeObject startTime) { LinearLayout layout = new LinearLayout(PlayBackActivity.this); layout.setOrientation(LinearLayout.VERTICAL); layout.setBackgroundColor(getResources().getColor(R.color.white)); final TimePicker mTimePicker = new TimePicker(PlayBackActivity.this); final DatePicker mDatePicker = new DatePicker(PlayBackActivity.this); mTimePicker.setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS); mTimePicker.setIs24HourView(true); mDatePicker.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS); final TextView tv = new TextView(PlayBackActivity.this); String time = String.format("%02d:%02d", startTime.getHour(), startTime.getMinute()); String date = String.valueOf(startTime.getYear()) + "年" + String.format("%02d", startTime.getMonth()) + "月" + String.format("%02d", startTime.getDay()) + "日"; tv.setText("开始时间:" + date + " " + time); int version = Integer.valueOf(android.os.Build.VERSION.SDK); if (version >= 11) mDatePicker.setCalendarViewShown(false); layout.addView(tv, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); layout.addView( mDatePicker, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); layout.addView( mTimePicker, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); new AlertDialog.Builder(PlayBackActivity.this) .setTitle("请选择结束时间:") .setView(layout) .setPositiveButton( android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { TimeObject endTime = new TimeObject( mTimePicker.getCurrentMinute(), mTimePicker.getCurrentHour(), mDatePicker.getDayOfMonth(), mDatePicker.getMonth() + 1, mDatePicker.getYear()); System.out.println("时间:" + endTime.getMinute() + " " + startTime.getMinute()); onTimeSearch(startTime, endTime); } }) .setNegativeButton( android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) {} }) .create() .show(); }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.user_info); ui_backButton.setOnClickListener(this); ui_nextButton.setOnClickListener(this); // do name field unselected imgName.setAlpha(100); // set click listener for TextViews tvLastName.setOnClickListener(this); tvName.setOnClickListener(this); fioKey_1.setOnClickListener(this); fioKey_2.setOnClickListener(this); fioKey_3.setOnClickListener(this); fioKey_4.setOnClickListener(this); fioKey_5.setOnClickListener(this); fioKey_6.setOnClickListener(this); fioKey_7.setOnClickListener(this); fioKey_8.setOnClickListener(this); fioKey_9.setOnClickListener(this); fioKey_10.setOnClickListener(this); fioKey_11.setOnClickListener(this); fioKey_12.setOnClickListener(this); fioKey_13.setOnClickListener(this); fioKey_14.setOnClickListener(this); fioKey_15.setOnClickListener(this); fioKey_16.setOnClickListener(this); fioKey_17.setOnClickListener(this); fioKey_18.setOnClickListener(this); fioKey_19.setOnClickListener(this); fioKey_20.setOnClickListener(this); fioKey_21.setOnClickListener(this); fioKey_22.setOnClickListener(this); fioKey_23.setOnClickListener(this); fioKey_24.setOnClickListener(this); fioKey_25.setOnClickListener(this); fioKey_26.setOnClickListener(this); fioKey_27.setOnClickListener(this); fioKey_28.setOnClickListener(this); fioKey_29.setOnClickListener(this); fioKey_30.setOnClickListener(this); fioKey_31.setOnClickListener(this); fioKey_Erase.setOnClickListener(this); newClient = new NewClient(UserInfoActivity.this); tvLastName.setText(newClient.lastName); tvName.setText(newClient.name); if (newClient.sex == 0) rSexWomen.setChecked(true); else rSexMen.setChecked(true); dBirthday.init(newClient.birthdayYear, newClient.birthdayMonth, newClient.birthdayDay, null); dBirthday.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS); /*File imgFile = new File("/sdcard/renter.png"); if (imgFile.exists()) { Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); ImageView imageRenterLogo = (ImageView) findViewById(R.id.imageRenterLogo); imageRenterLogo.setImageBitmap(myBitmap); }*/ }