Skip to content Skip to sidebar Skip to footer

Textview Always Showing Value As "0" On Ui

I am using a simple TextView and updating its value in onPostExecute of a AsyncTask. But every time its showing '0' on UI. My code is: TextView tv = (TextView)findViewById(R.id.tv)

Solution 1:

Your code tv.setText(calculation()); tryind to take string from Resourses cause you set value as int.

Use tv.setText(String.valueOf(calculation()));

Solution 2:

try this

tv.setText(calculation()+"");

As TextView only accept string in settext, Adding +"" to int will make it as string. and make sure that your method is returning the right value.

Post a Comment for "Textview Always Showing Value As "0" On Ui"