I need to use TimePicker in several buttons on the same screen, and each one will save information in a different variable, but whenever I try to create another it will not work if I know of any way I can reuse it or create other ones. >
code that I'm trying to use
public void showTimePicker(View view){
button = (Button) findViewById(R.id.acorda);
button.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v) {
showDialog(DIALOG_ID);
}
}
);
@Override
protected Dialog onCreateDialog(int id ){
if (id == DIALOG_ID)
return new TimePickerDialog(EscolhaAguaCasa.this, kTimePickerListener
, hourxUM ,minutexUM, false);
return null ;
}
protected TimePickerDialog.OnTimeSetListener kTimePickerListener = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
hourxUM = hourOfDay;
minutexUM = minute;
}
} ;
public void Segundachamada(View view){
button = (Button) findViewById(R.id.dorme);
button.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v) {
showDialog(DIALOG_ID);
}
}
);
}
protected Dialog onCreateDialogg(int id ){
if (id == DIALOG_ID)
return new TimePickerDialog(EscolhaAguaCasa.this, kTimePickerListenerr , hourxDOIS ,minutexDOIS, true);
return null ;
}
protected TimePickerDialog.OnTimeSetListener kTimePickerListenerr = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
hourxDOIS = hourOfDay;
minutexDOIS = minute;
}
};