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 关于#flink#的问题:关于docker部署flink集成hadoop的yarn,请教个问题flink启动yarn-session.sh连不上hadoop
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题