Reputation: 6188
timePicker = (TimePicker) findViewById(R.id.tijd);
timePicker.setOnClickListener(this);
klaar = (Button) findViewById(R.id.klaar);
klaar.setOnClickListener(this);
Does anyone know why only the Button triggers an onClick? The setOnClickListener on the timePicker doesn't seem to be working
edit: onclicklistener added, my main class implements onClickListener
public void onClick(View v) {
Log.d("temp", "View clicked");
}
Upvotes: 0
Views: 1306
Reputation: 134664
What click are you trying to capture? There are several views inside a TimePicker; looking here, TimePicker has an OnTimeChangedListener
you can use, which seems more like what you would want. I imagine you could do timePicker.setClickable(true)
to set the entire view to be clickable, but I don't think that would give the results you're looking for. Alternatively, take a look at the TimePickerDialog
example to see an example adapting a TimePicker into a dialog with a Set and Cancel button using an OnTimeSetListener
.
Upvotes: 3
Reputation: 3445
First comment is sensible. We can't answer you until we read onClick() method. But I can suggest you to implement click listeners in separate methods:
timePicker = (TimePicker) findViewById(R.id.tijd);
timePicker.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// method for timePicker
}
});
klaar = (Button) findViewById(R.id.klaar);
klaar.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// method for button
}
});
Upvotes: 0