I have this activity:
package zh.wang.android.yweathergetter;
import greendroid.app.GDActivity;
import zh.wang.android.utils.YahooWeather4a.WeatherInfo;
import zh.wang.android.utils.YahooWeather4a.YahooWeatherInfoListener;
import zh.wang.android.utils.YahooWeather4a.YahooWeatherUtils;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity implements YahooWeatherInfoListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
YahooWeatherUtils yahooWeatherUtils = YahooWeatherUtils.getInstance();
yahooWeatherUtils.queryYahooWeather(getApplicationContext(), "Madrid", this);
}
@Override
public void gotWeatherInfo(WeatherInfo weatherInfo) {
// TODO Auto-generated method stub
if(weatherInfo != null) {
TextView tv = (TextView) findViewById(R.id.textview_weather_info);
tv.setText(weatherInfo.getTitle() + "\n"
+ weatherInfo.getLocationCity() + ", "
+ weatherInfo.getLocationCountry() + "\n"
+ "Climatología: " + weatherInfo.getCurrentText() + "\n"
+ "Temperatura actual: " + weatherInfo.getCurrentTempC() + "ºC"+ "\n"
+ "Previsión para mañana: " + weatherInfo.getForecast1Text() + "\n"
+ "Previsión para pasado mañana: " + weatherInfo.getForecast2Text());
}
}
}
I have also set up GD Library,but when I change "activity" to "GDActivity" and "setContentView" to "setActionBarContentView" my App ForceCloses. Sorry for my english.
Are you using the latest version of YWeatherGetter4a lib? If not, you need to set textview's text in another thread, for example, using an AsyncTask class.