亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Arraylist 顯示此值 PlanetData@adf4bee 而不是附加值

Arraylist 顯示此值 PlanetData@adf4bee 而不是附加值

慕萊塢森 2022-01-12 14:44:00
我不確定我的主題是否提出了正確的問題,但情況就是這樣。我正在開發一個在單獨的類中執行多個計算的應用程序。計算正確完成,我可以看到它們在 logcat 中?,F在我想在 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);        }    }
查看完整描述

1 回答

?
喵喔喔

TA貢獻1735條經驗 獲得超5個贊

默認情況下,toString()方法將導致packagename.ClassName@hashcode.

在您的PlanetData類中,您需要重寫toString()方法,以便它可以返回適當的字段及其值。

您可以toString()使用 IDE生成方法并選擇要包含在輸出中的字段。


查看完整回答
反對 回復 2022-01-12
  • 1 回答
  • 0 關注
  • 134 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號