AnnBnnCnnD 2013-04-23 05:34 采纳率: 0%
浏览 2092
已采纳

列表视图中传递int值到string值

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

有一个全是string值的列表视图。我将注释放到int值中,然后将int值传递过去,但是总是报出空指针异常。应该怎么解决?

我用到JSONboject。

  • 写回答

2条回答 默认 最新

  • AnnBnnCnnD 2013-04-24 05:36
    关注

    我找到的实现方法:String.valueOf(Voicenames.get(position).getWhatever());

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器