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

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

將列表添加到 ArrayList<String> 并在 ListView 上顯示

將列表添加到 ArrayList<String> 并在 ListView 上顯示

嚕嚕噠 2021-07-12 13:05:20
我想從我從 TimePicker 獲得的時間開始制作 ListView 我成功地將時間添加到變量中。但是當我嘗試將它們添加到 ListView 時,我什么也沒得到。    addArray = new ArrayList<String>();    ArrayAdapter<String> adapter = new ArrayAdapter(chart_houres_cosher.this,android.R.layout.simple_list_item_1,addArray);    ListView listView = (ListView) findViewById(R.id.leassons);    listView.setAdapter(adapter);單擊按鈕    textView.setText( firstHouer + " : " + firstdMinute + " - " + seccoundHouer + " : " + seccoundMinute );    addArray.add(firstHouer + " : " + firstdMinute + " - " + seccoundHouer + " : " + seccoundMinute);我可以在 TextView 上看到結果,但在 ListView 上看不到。
查看完整描述

2 回答

?
慕尼黑8549860

TA貢獻1818條經驗 獲得超11個贊

你的數據在哪里?從您的代碼中,您正在嘗試添加一個空數組。

addArray = new ArrayList<String>();

你只是聲明了addArray,它里面沒有任何數據。您正在向 ListView 添加空數組。


查看完整回答
反對 回復 2021-07-14
  • 2 回答
  • 0 關注
  • 284 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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