[問題] android app新手觀念一問
因為剛開始自學android 程式編輯,有個問題困擾我,以Java來說假設有個Dog class,要
創造他的物件就Dog x = new Dog();
但在android studio寫程式,在畫面編輯拉一個TextView到手機畫面,id設定為txv,然
後在邏輯編輯處只會寫到例如 TextView txv=(TextView)findViewById(R.id.txv),將畫
面物件與程式做連結,但並沒有以TextView txv = new TextView()來創物件,但又有看
到
Random用法,書本有用Random x= new Random()創Random物件,有點搞不清楚何時要new何
時不用,麻煩各位指導小弟,感恩
--
Sent from my Android
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.12.146.158
※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1462781245.A.FB1.html
※ 編輯: apout (101.12.146.158), 05/09/2016 16:08:05
→
05/09 16:18, , 1F
05/09 16:18, 1F
→
05/09 16:18, , 2F
05/09 16:18, 2F
所以我才想問不用寫程式建立TextView這個物件嗎?還是拉TextView到編輯畫面時
自動建立了?搞不懂
※ 編輯: apout (101.12.146.158), 05/09/2016 16:22:42
→
05/09 16:23, , 3F
05/09 16:23, 3F
→
05/09 16:24, , 4F
05/09 16:24, 4F
→
05/09 16:26, , 5F
05/09 16:26, 5F
所以會在setContentView後自動建立,原來如此,感謝大大說明
※ 編輯: apout (101.12.146.158), 05/09/2016 16:35:04