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());

i have here a listview of string value and i put comment on int value i cant pass an int value for it how can i pass an int value to string so that the null pointer exception will not show anymore?JSONboject are used here

2 Answers 2

3

You can use:

String.valueOf(Voicenames.get(position).getWhatever());
Sign up to request clarification or add additional context in comments.

3 Comments

bah, you beat me to answering this by 1 second.
look at the comment i tried it but it doesnt work have a detail file saying the those four are int then getting it as in doesnt work at all
perfect code.you know how to put image from url?same problem with int
2

Wrap those getter's in 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()) );

1 Comment

perfect.1 more thing same problem but with image view from a url i tried several tutorial but i failed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.