Reputation: 53600
In my activity I have a time picker. I implemented call backs as you can see below but there is no log that shows none of them have been called. Regardless of setting tpTimer.setFocusable()
to True
or False
, none of them called.
Any suggestion would be appreciated.
TimePicker tpTimer = (TimePicker) findViewById(R.id.timePicker);
tpTimer.setIs24HourView(true);
tpTimer.setCurrentHour(0);
tpTimer.setCurrentMinute(0);
tpTimer.setFocusable(false); // or True
tpTimer.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, "%1");
}
});
tpTimer.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
Log.i(TAG, "%2");
}
});
tpTimer.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Log.i(TAG, "%3");
return false;
}
});
tpTimer.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.i(TAG, "%4");
return false;
}
});
Upvotes: 0
Views: 366
Reputation: 14622
I had the same problem. My workaround is to use the setOnTimeChangedListener:
tpTimer.setOnTimeChangedListener(new OnTimeChangedListener() {
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
//Do whatever you want here
}
});
Hope it helped you as well, and I hope there will be peace between our countries (Iran and Israel).
Upvotes: 0
Reputation: 1033
The methods gets called if you mention the view so change all the event listener code to
tpTimer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i("Message", "Its Clicked");
}
});
I hope this helps.
Upvotes: 1