java - setText not displaying the value to a TextView -


let me preface i'm new programming android. i've been doing due diligence research no avail. have source code below , i'm having issues returning value returning.

i have code laid out on eclipse , it's not triggering errors. when build code below, comes error. after inspecting values in debug view, can see proper values not binded textview.

public class myfirstactivity extends activity { /** called when activity first created. */   @override   public void oncreate(bundle savedinstancestate) {       super.oncreate(savedinstancestate);       setcontentview(r.layout.main);       calculateresult(2012, 9, 29);   }   private void calculateresult(int year, int month, int day) {       long days = 0l;       int returning = 0;        java.util.calendar cal = new java.util.gregoriancalendar(year, month-1, day);        long todaymi = new java.util.date().gettime();       long calmi = cal.gettimeinmillis();       long milldiff = calmi - todaymi;        if (milldiff < 0) {             returning = 0;       } else {             days = milldiff / 1000 / 60 / 60;             returning = (int) math.ceil(days / 24f);       }        textview days_int_remaining = (textview) findviewbyid(r.id.days_int_remaining);       days_int_remaining.settext(returning);   } } 

if helps, here's textview on layout xml:

<textview       android:id="@+id/days_int_remaining"       android:layout_height="wrap_content"       android:layout_width="wrap_content"       android:layout_gravity="center_horizontal|center_vertical"       android:shadowcolor="#5000"       android:shadowdx="4"       android:shadowdy="3"       android:shadowradius="1"       android:textcolor="#fff"       android:textsize="70dip"       android:textstyle="bold" /> 

it may simple i'm missing. me further understand code appreciated!

just use

textview days_int_remaining = (textview) findviewbyid(r.id.days_int_remaining); days_int_remaining.settext(string.valueof(returning)); 

instead of

textview days_int_remaining = (textview) findviewbyid(r.id.days_int_remaining); days_int_remaining.settext(returning); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -