我有这个代码
package com.lestijden;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
TextView Datum;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Datum = (TextView) findViewById(R.id.Tijd);
Date today = Calendar.getInstance().getTime();
SimpleDateFormat Formatter = new SimpleDateFormat("km");
String folderName = Formatter.format(today);
int result = folderName.compareTo("0");
if (result > 815 ){
double data = new Double("905") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 905){
double data = new Double("955") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 955){
double data = new Double("1045") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 1045){
double data = new Double("1100") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 1100){
double data = new Double("1150") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 1150){
double data = new Double("1240") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 1240){
double data = new Double("1310") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 1310){
double data = new Double("1400") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 1400){
double data = new Double("1450") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 1450){
double data = new Double("1505") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 1505){
double data = new Double("1555") - new Double(folderName);
Datum.setText(Double.toString(data));
}
else if (result > 1555){
double data = new Double("1645") - new Double(folderName);
Datum.setText(Double.toString(data));
}
}
}
我希望它像这样工作:如果时间是例如 14:01。(1401) 然后它需要计算 1450 减去当前时间 (1401)。并在文本视图中显示输出 (49)。
我的 textview 不显示任何输出。我该如何解决这个问题?