Let me preface that I'm new to programming for Android. I've been doing my due diligence to research to no avail. I have the source code below and I'm having issues with returning the value for returning.
I have the code laid out on eclipse and it's not triggering any errors. But when I build the code below, it comes back with an error. After inspecting the values in debug view, I can see the proper values just not binded to the TextView.
public class MyFirstActivity extends Activity {
/** Called when the activity is 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 it helps, here's the TextView on my 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 be something simple that I'm missing. Anything to help me further understand the code is appreciated!