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!
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 trial

James Allgood
157 Pointssomeone PLEASE help
right I'm very new to coding and need help... ive got a number picker and i want it to go up or down by one when a button is press I want to make it as simple as possible im using eclipse ive been looking on the internet all day and ive got no where
thanks for the help in advance
8 Answers

samiff
31,206 PointsPost your code that you have so far, and that will make helping you a lot easier.

James Allgood
157 PointsI havent got anything i dunno what to do to do it

samiff
31,206 PointsSounds like you should take a look at Introduction to Programming. Although that uses JavaScript (unrelated to Java), it's a good way to start understanding programming.
I'm not sure exactly what you're trying to create, but the way something like that would work is that you'd have a variable, let's say clickCount, that would store a value.
You could then have a button which would contain an event handler (the event would be someone clicking it). Each time the button is clicked, the event handler is called, and code can be ran that would add/subtract from your clickCount variable.
Any reason you started with Java/Android/Eclipse in particular?

James Allgood
157 PointsIm just trying to make a app to counts something if i click the plus button on a number picker or button and eclipse was the software treehouse said to use

James Allgood
157 Points
James Barnett
39,199 Points@James Allgood - There's a whole course here on Treehouse for learning to program on Android

James Allgood
157 Pointsyeah ive done the course I must have to use something like a on click listener then from there onwards I become stuck ive looked on google and theres nothing i can find and get it to work

Nathan Kluth
12,124 PointsHi James. Here is what I come up with. It's pretty crude, so you'll have to tweak it from here :)
public class MainActivity extends Activity {
Integer i = 20;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button up = (Button) findViewById(R.id.button1);
Button down = (Button) findViewById(R.id.button2);
final TextView text = (TextView) findViewById(R.id.textView1);
text.setText("20");
up.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
i++;
text.setText(i.toString());
}
});
down.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
i--;
text.setText(i.toString());
}
});
}