I'm trying to keep my code more developer friendly. Originally I have set up a button with a standard on click listener which simply increase the value of a edit text by 1 each time its pressed.
Now in order to try keep it more organised I'm trying to move the on click listener to its own class which will host a range of switch statements. The only problem I'm experiencing is the ability to set up a getter and setter for my method.
This is my current on click listener
testButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int time = Integer.valueOf(editHours.getText().toString());
time++;
editHours.setText(Integer.toString(time));
}
});
This is my separate case statement which can be linked in at a later point.
public class MyClickListener implements View.OnClickListener {
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.testingButton:
Log.i("Test", "Complete");
break;
I'm only stuck on the ability to set up getter and setter. Which takes the current value with the getter and then finally use the setter to set the new value.
Also as a side note you have noticed that I haven't demonstrated my own getter and setter that is because I'm slightly confused about how to do this for this method.
Thank you