第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

在 Textview 來查看數(shù)據(jù)庫

在 Textview 來查看數(shù)據(jù)庫

猛跑小豬 2019-03-22 23:19:43
我想在 activity 中使用一個 Textview 來查看數(shù)據(jù)庫。setText()代碼:@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_viewlogs);  TextView tv = (TextView) findViewById(R.id.tvSqlinfo); LogsDB info = new LogsDB(this); info.open(); ArrayList<String> data = info.getData(); info.close(); tv.setText(data); }好像在 tv.setText(data);處獲的錯誤:"The method setText(CharSequence) in the type TextView is not applicable for the arguments (ArrayList)"。然后當(dāng)我建議修復(fù)時,tv.setText(data)就變成 tv.setText((CharSequence) data);。當(dāng)我檢測程序時,有錯誤顯示它不能被cast。如何在 Textview 來查看數(shù)據(jù)庫?
查看完整描述

1 回答

?
墨色風(fēng)雨

TA貢獻(xiàn)1853條經(jīng)驗 獲得超6個贊

0.0 你的data是個Arrylist,把它里面的數(shù)據(jù)遍歷出來再settext();

ArrayList data = info.getData();
info.close();
String s = "";
//數(shù)據(jù)多的時候用線程遍歷~
for(int i = 0; i<data.size(); i++){
s = s + data.get(i);
}
tv.setText(s);


查看完整回答
反對 回復(fù) 2019-04-30
  • 1 回答
  • 0 關(guān)注
  • 397 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號