Set Text to Integer Value

Generally,

tv.setText(String.valueOf(int));

If the value is inside another class? You can make a getter for the value you want in that class:

public int getValue() {
    return value;
}

So that you can access it from the other one:

BUT if you set a TextView to an int, it will be interpreted as an Android resource id. If you want the value of the int as your text (and not the resource it points to), make it a String first.

tv.setText(String.valueOf(theOtherClassInstance.getValue()));

EDIT If your int is firstResult as per your comment below, then the getter becomes:

public int getFirstResult() {
    return firstResult;
}

Leave a Comment