推 voickylin: 應該是順序問題,再看看其他範例的說明吧 12/23 09:16
→ lnmlee: 加個轉型看看 12/23 09:46
→ taco2548: 轉哪 12/23 09:56
→ cha122977: 有enter_dialog.xml原始碼嗎? 12/23 12:42
→ lnmlee: findView 完轉型 TextView 12/23 13:04
→ erty0402: 轉型是下一個問題 12/23 13:26
→ roy870075: 你要在onCreateView做不是onCreateDialog… 12/23 17:22
→ taco2548: onCreateView也做過了,一樣結果 12/23 17:48
→ taco2548: 事實上若是寫在show之前,是可以運作的,像這樣 12/23 17:49
→ taco2548: 但如果在show之後,infoText就不見了 12/23 17:52
→ taco2548: 因為我還要用EditText跟Button,要取得用戶的動作跟輸入 12/23 17:55
※ 編輯: taco2548 (223.138.138.92), 12/23/2017 17:57:47
→ taco2548: 但我在show之後,所有東西都是空的,view也是 12/23 18:03
→ roy870075: 那試試寫在onViewCreated呢? 12/23 19:01
→ salavida: show只是開啟一個transcation說要加入一個fragment 12/24 00:12
→ salavida: 所以fragment並沒有立刻生成好 12/24 00:13
→ salavida: 把setInfoText換成印log然後onCreateDialog第一行印log 12/24 00:16
→ salavida: 看一下log順序 12/24 00:16
→ taco2548: log順序確實是像大大說的一樣,show排超後面 12/25 11:39
→ taco2548: 請問該怎麼解決這個問題? 12/25 11:40
→ taco2548: 找到答案了 executePendingTransactions() ,,非常感謝 ! 12/25 11:44
→ qweqweqweqwe: 比較建議用setArguments... 12/30 04:32
→ qweqweqweqwe: 另外在 onCreateDialog 內就可以了 12/30 04:33