Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJoshua Douce
13,120 PointsHere's a simple counter app consisting of only a TextView and a Button. When the Button is pressed the counter (TextView
I keep getting this error public MainActivityPresenter(MainActivityView)
I have checked, double checked and triple checked still no joy. Have i got his wrong or is there something wrong with the code challenge?
public class MainActivity extends AppCompatActivity implements MainActivityView {
TextView counter;
Button button;
MainActivityPresenter presenter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
presenter = new MainActivityPresenter(this);
counter = (TextView) findViewById(R.id.textView);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int count = Integer.parseInt(counter.getText().toString());
presenter.updateCounterTextView(count + "");
}
});
}
@Override
public void changeTextViewText(String text) {
counter.setText(text);
}
}
public interface MainActivityView {
void changeTextViewText(String text);
}
public class MainActivityPresenter {
MainActivityView newView;
public MainActivityPresenter(MainActivityView view) {
newView = view;
} // MainActivityPresenter()
public void updateCounterTextView(String text){
newView.changeTextViewText(text);
}
}
1 Answer
Seth Kroger
56,414 PointsYou're forgetting to add one to the count.
Joshua Douce
13,120 PointsJoshua Douce
13,120 PointsOh dear, spent hours looking at the syntax and never checked that i was increasing by one. Thank you