我的代码
timePickerBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TimePickerDialog timePickerDialog = new TimePickerDialog(NewTaskActivity.this, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int hourOfDay, int Minute) {
TimeHour = hourOfDay;
TimeMinute = Minute;
Calendar calendarTime = Calendar.getInstance();
calendarTime.set(0,0,0, TimeHour, TimeMinute);
timePickerBTN.setText(android.text.format.DateFormat.format("hh:mm aa", calendarTime));
}
},12,0,false);
timePickerDialog.updateTime(TimeHour, TimeMinute);
timePickerDialog.show();
}
});
我想在设置 * timePickerBTN文本后访问它 * timePickerBTN. setText(android. text. format. DateFormat. format("hh:mm aa",calendarTime)); * 在OnTimeSet中**
我想将timePickerBTN文本(拾取时间之后)设置为TextView文本
(EDIT)尝试此方法太多enter image description here
1条答案
按热度按时间wooyq4lh1#
使用getText()获取Button的文本,即
您的代码如下所示