Java 在我使用updateDisplay方法之前,一切都正常,导致应用程序崩溃

Java 在我使用updateDisplay方法之前,一切都正常,导致应用程序崩溃,java,android,json,api,settext,Java,Android,Json,Api,Settext,所有内容都会正确显示在屏幕上,直到我用代码填写updateDisplay()方法,以使用setText/get更新我的textview 在从DarkSky API输入要更新的setText/get代码之前,应用程序不会崩溃,但一旦输入,应用程序就会崩溃并告诉我重试 我相信所有信息都输入正确,但由于某些原因,应用程序不会接收信息。另外,我在摇篮中使用了最新版本的OkHTTP,所以问题不在这里。(还使用了权限) 包裹tricksterantics.com.catsndogs import java.

所有内容都会正确显示在屏幕上,直到我用代码填写
updateDisplay()
方法,以使用
setText/get
更新我的
textview

在从DarkSky API输入要更新的
setText/get
代码之前,应用程序不会崩溃,但一旦输入,应用程序就会崩溃并告诉我重试

我相信所有信息都输入正确,但由于某些原因,应用程序不会接收信息。另外,我在摇篮中使用了最新版本的OkHTTP,所以问题不在这里。(还使用了权限)

包裹tricksterantics.com.catsndogs

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class CurrentWeather {
    private String mIcon;
    private long mTime;
    private double mTemperature;
    private double mHumidity;
    private double mPrecipChance;
    private String mSummary;


public String getTimeZone() {
    return mTimeZone;
}

public void setTimeZone(String timeZone) {

    mTimeZone = timeZone;
}

private String mTimeZone;

public String getIcon() {

    return mIcon;
}


public void setIcon(String icon) {

    mIcon = icon;
}

public int getIconId() {
    // clear-day, clear-night, rain, snow, sleet, wind, fog, cloudy, partly-cloudy-day, or partly-cloudy-night.
    int iconId = R.drawable.clear_day;

    if (mIcon.equals("clear-day")) {
        iconId = R.drawable.clear_day;
    }
    else if (mIcon.equals("clear-night")) {
        iconId = R.drawable.clear_night;
    }
    else if (mIcon.equals("rain")) {
        iconId = R.drawable.rain;
    }
    else if (mIcon.equals("snow")) {
        iconId = R.drawable.snow;
    }
    else if (mIcon.equals("sleet")) {
        iconId = R.drawable.sleet;
    }
    else if (mIcon.equals("wind")) {
        iconId = R.drawable.wind;
    }
    else if (mIcon.equals("fog")) {
        iconId = R.drawable.fog;
    }
    else if (mIcon.equals("cloudy")) {
        iconId = R.drawable.cloudy;
    }
    else if (mIcon.equals("partly-cloudy-day")) {
        iconId = R.drawable.partly_cloudy;
    }
    else if (mIcon.equals("partly-cloudy-night")) {
        iconId = R.drawable.cloudy_night;
    }

    return iconId;
}

public long getTime() {

    return mTime;
}

public void setTime(long time) {

    mTime = time;
}
public String getFormattedTime () {
    SimpleDateFormat formatter = new SimpleDateFormat("h:mm a");
    formatter.setTimeZone(TimeZone.getTimeZone(getTimeZone()));
    Date dateTime = new Date(getTime() * 1000);
    String timeString = formatter.format(dateTime);

    return timeString;
}

public double getTemperature() {

    return (int) Math.round(mTemperature);
}

public void setTemperature(double temperature) {

    mTemperature = temperature;
}

public double getHumidity() {

    return mHumidity;
}

public void setHumidity(double humidity) {

    mHumidity = humidity;
}

public int getPrecipChance() {
    double precipPercentage = mPrecipChance * 100;

    return (int) Math.round(precipPercentage);
}

public void setPrecipChance(double precipChance) {

    mPrecipChance = precipChance;
}

public String getSummary() {

    return mSummary;
}

public void setSummary(String summary) {

    mSummary = summary;
}
}

编辑: 添加了堆栈跟踪的图像

摆脱了我使用的Butterknife格式(BindVIew),选择了这种格式,现在一切正常,正在从API检索更新信息:

公共类MainActivity扩展了AppCompatActivity{

public static final String TAG = MainActivity.class.getSimpleName();

private CurrentWeather mCurrentWeather;

private TextView mTimeLabel;

private TextView mTempLabel;

private TextView mHumidityValue;

private TextView mPrecipValue;

private TextView mSummaryLabel;

private ImageView mIconImageView;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTimeLabel = (TextView) findViewById(R.id.timeLabel);
    mTempLabel = (TextView) findViewById(R.id.tempLabel);
    mHumidityValue = (TextView) findViewById(R.id.humidityValue);
    mPrecipValue = (TextView) findViewById(R.id.precipValue);
    mSummaryLabel = (TextView) findViewById(R.id.summaryLabel);

发布崩溃中的堆栈跟踪。另外,继续并检查该方法中没有任何内容是空的。这可能是我们目前显示的问题。我已经添加了堆栈跟踪的屏幕截图。我不认为它是空的?我不太确定堆栈跟踪是否非常清楚-您正在尝试引用空对象-可能是使用settex我对应用程序开发非常陌生,所以我不确定我应该从那里做什么,因为它是空的?
public static final String TAG = MainActivity.class.getSimpleName();

private CurrentWeather mCurrentWeather;

private TextView mTimeLabel;

private TextView mTempLabel;

private TextView mHumidityValue;

private TextView mPrecipValue;

private TextView mSummaryLabel;

private ImageView mIconImageView;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTimeLabel = (TextView) findViewById(R.id.timeLabel);
    mTempLabel = (TextView) findViewById(R.id.tempLabel);
    mHumidityValue = (TextView) findViewById(R.id.humidityValue);
    mPrecipValue = (TextView) findViewById(R.id.precipValue);
    mSummaryLabel = (TextView) findViewById(R.id.summaryLabel);