2013-04-23 30 views
2
TextView location=(TextView)template_view.findViewById(R.id.tvlocation); 
    TextView weather=(TextView)template_view.findViewById(R.id.tvweather); 
    TextView temp=(TextView)template_view.findViewById(R.id.tvtemp); 
    TextView dewpoint=(TextView)template_view.findViewById(R.id.tvdew); 
    TextView humidity=(TextView)template_view.findViewById(R.id.tvhumidity); 
    TextView windspeed=(TextView)template_view.findViewById(R.id.tvspeed); 
    TextView winddir=(TextView)template_view.findViewById(R.id.tvdir); 
    TextView windgust=(TextView)template_view.findViewById(R.id.tvgust); 
    TextView pressure=(TextView)template_view.findViewById(R.id.tvcondition); 
    TextView heatindex=(TextView)template_view.findViewById(R.id.tvheat); 
    TextView visibility=(TextView)template_view.findViewById(R.id.tvvisibility); 
    TextView precipitation=(TextView)template_view.findViewById(R.id.tvprecipitation); 
    TextView dailyprecipitation=(TextView)template_view.findViewById(R.id.tvdaily); 
    TextView sunrise=(TextView)template_view.findViewById(R.id.tvsunrise); 
    TextView sunset=(TextView)template_view.findViewById(R.id.tvsunset); 

    location.setText(Voicenames.get(position).getLocation()); 
    weather.setText(Voicenames.get(position).getWeather()); 
    //temp.setText(Voicenames.get(position).getTemp_c()); 
    //dewpoint.setText(Voicenames.get(position).getDewpoint_c()); 
    //windspeed.setText(Voicenames.get(position).getWind_kph()); 
    //windgust.setText(Voicenames.get(position).getWind_gust_kph()); 
    humidity.setText(Voicenames.get(position).getRelative_humidity()); 
    winddir.setText(Voicenames.get(position).getWind_dir()); 
    pressure.setText(Voicenames.get(position).getPressure_mb()); 
    heatindex.setText(Voicenames.get(position).getHeat_index_c()); 
    visibility.setText(Voicenames.get(position).getVisibility_km()); 
    precipitation.setText(Voicenames.get(position).getPrecipitation()); 
    dailyprecipitation.setText(Voicenames.get(position).getDaily_precipitation()); 
    sunrise.setText(Voicenames.get(position).getSunrise()); 
    sunset.setText(Voicenames.get(position).getSunset()); 

我在這裏列表視圖的字符串值,我把註釋放在int值我不能傳遞一個int值它如何傳遞一個int值給字符串,以便null指針異常將不再顯示JSONboject這裏在列表視圖中將int值傳遞到字符串

回答

3

使用您可以使用:?

String.valueOf(Voicenames.get(position).getWhatever()); 
+0

唉,你打我回答這個1秒。 – Jschools 2013-04-23 01:02:34

+0

看看評論我試過了,但它不工作有一個詳細的文件說,這四個是int然後得到它,因爲在工作根本沒有 – Giant 2013-04-23 01:03:55

+0

你可以發佈logcat錯誤 – RyPope 2013-04-23 01:07:43

2

總結那些吸在String.valueOf

temp.setText(String.valueOf(Voicenames.get(position).getTemp_c())); 
dewpoint.setText(String.valueOf(Voicenames.get(position).getDewpoint_c())); 
windspeed.setText(String.valueOf(Voicenames.get(position).getWind_kph())); 
windgust.setText(String.valueOf(Voicenames.get(position).getWind_gust_kph())); 
+0

完全相同的問題perfect.1更多的事情相同的問題,但從圖像視圖從一個URL我嘗試了幾個教程,但我失敗了。 – Giant 2013-04-23 01:08:26

相關問題