我不确定我的主题是否提出了正确的问题,但情况就是这样。我正在开发一个在单独的类中执行多个计算的应用程序。计算正确完成,我可以看到它们在 logcat 中。现在我想在 recyclerview 中显示它们,为此我试图在执行 recyclerview 之前将它们添加到数组列表中。我的数组列表正在获取标题中显示的值,而它没有显示在我的回收站视图中。这是我的代码,但根据我查找的研究,我看不出我做错了什么。
数组列表代码:
public class PlanetData {
private String planetRA;
private PlanetData(String planetRA){
this.planetRA = planetRA;
}
public String getPlanetRA(){
return planetRA;
}
public void setPlanetRA (String planetRA){
this.planetRA = planetRA;
}
public static void main(String [] args){
List<PlanetData> planetvalues = new ArrayList<>();
planetvalues.add(new PlanetData("12"));
planetvalues.add(new PlanetData(Double.toString(Mercury.getMercuryRA())));
planetvalues.add(new PlanetData(Double.toString(Venus.getVenusRA())));
planetvalues.add(new PlanetData(Double.toString(Moon.getMoonRA())));
planetvalues.add(new PlanetData (Double.toString(Mars.getMarsRA())));
planetvalues.add(new PlanetData(Double.toString(Jupiter.getJupiterRA())));
planetvalues.add(new PlanetData(Double.toString(Saturn.getSaturnRA())));
planetvalues.add(new PlanetData(Double.toString(Uranus.getUranusRA())));
planetvalues.add(new PlanetData(Double.toString(Neptune.getNeptuneRA())));
planetvalues.add(new PlanetData(Double.toString(Pluto.getPlutoRA())));
System.out.println("This is the arraylist" + planetvalues);
}
}
RecyclerView 适配器
public class PlanetRecyclerViewAdapter extends RecyclerView.Adapter<PlanetRecyclerViewAdapter.ViewHolder> {
List<PlanetData> mPlanetDataList;
Context mContext;
public static class ViewHolder extends RecyclerView.ViewHolder{
public TextView currentRA;
public ViewHolder(View itemView) {
super(itemView);
currentRA = (TextView) itemView.findViewById(R.id.planet_location);
}
}
喵喔喔
相关分类