• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android Dev: Increase value of TextView

mineko

Lurker
I am Computer Engineering student taking up my internship and my boss assigned to me on developing an app for scoreboard. And I am having a hard time for I don't have much background to Java as well as the Android.

Can anyone help me please?

I am developing my program but it seems It really giving me hard time regarding TextView.XD

How do you increase the value of TextView where its value is e.g. is 0?
Just like in Scoreboard. Increasing the value of score as you click the TextView assigned to it.

This is my code:

private OnClickListener mHscoreListener = new OnClickListener() {
public void onClick(View v) {
//DO INCREASE
}; };

Any help would be appreciated. TY!


:) :) :) :) Arghh hard to self-study lol XD
 
I would simply make an int variable that counts up on every click and set the textview accordingly. Something like:

Code:
private int count;
private TextView counterText;

public void onCreate(){
...
counterText = findViewById(R.id.your_textview_id);
...
}

...
//DO INCREASE
count++; //Counts up with 1
counterText.setText("" + count);
...
 
Back
Top Bottom