Reputation: 663
I am really struggling with somthing that is probably really simple.
I have a time picker with an id of timePicker1 and when it is changed I want to instantly change the time in a text box with an id of echoTime. Now when the activity starts it displays the current time from the time picker. But when I scroll through the hours and minutes I need it to change the value in my textView echoTime.
Can anyone tell me what I am doing wrong
Here is file :
public class AddNormal extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.add_normal);
// the callback received when the user "sets" the time in the dialog
//TimePicker timePicker1 = (TimePicker) findViewById(R.id.timePicker1);
//timePicker1.clearFocus();
//int hour = timePicker1.getCurrentHour();
//int minute = timePicker1.getCurrentMinute();
//TextView echoTime = (TextView) findViewById(R.id.echoTime);
//echoTime.setText(hour +":"+ minute );
}
void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
TextView echoTime = (TextView) findViewById(R.id.echoTime);
echoTime.setText(hourOfDay +":"+ minute );
}
};
Thanks In advabce peeps.
Upvotes: 0
Views: 155
Reputation: 1007349
Call setOnTimeChangedListener()
on the TimePicker
and provide an implementation of OnTimeChangedListener
to be notified when the time in the TimePicker
changes.
Upvotes: 1