看板 AndroidDev 關於我們 聯絡資訊
程式碼在這邊 http://nopaste.csie.org/8dafe 我要問的是 我今天是跟著 Android手機應用程式入門 這本書 打出來的程式 可是當我做到第12章加入對話框時 private void openOptionsDialog(){ new AlertDialog.Builder(this) .setTitle(R.string.about_title) .setMessage(R.string.about_msg) .show(); } 第二行那一段程式碼都會顯示錯誤 AlertDialog ←這個底下都會顯示紅線 (我是用eclipse) 就無法執行了 跟著課本弄了好幾次都不太知道錯誤在哪裡 我在猜是不是上面import 上面要導入新的 可是網路上查到的放進去也無法正常編譯 想請問各位大大我該怎麼修改呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 175.181.206.51
abccbaandy:如果是import的問題的話,滑鼠移到錯誤的地方會有選項 05/03 20:08
它叫我說要輸入 import adroid.app.AlertDialog; 可是我打了輸入了也沒有用 ※ 編輯: sillysmile 來自: 175.181.206.51 (05/03 20:16)
swda289346:把new去掉 05/03 20:26
沒辦法= =... ※ 編輯: sillysmile 來自: 175.181.160.103 (05/03 23:07)
jason860421:試試看AlertDialog.Builder XXX =new AlertDialog.Bui 05/03 23:20
jason860421: lder(xxx.this) 05/03 23:20
swda289346:我弄錯了 樓上正解 05/03 23:24
pd760323:紅底線會寫原因吧? 05/03 23:32
lovelycateye:Code沒錯 1.沒import 2.strings.xml沒定義這兩個 05/04 00:51
lovelycateye:http://nopaste.csie.org/1d655 剩2.可能有問題 05/04 01:05
lovelycateye:Code我搬過了 openOptionsDialog怎會放在Listener 05/04 01:06
cobrasgo:試試先clear,然後直接run不要鳥紅線 05/04 20:54
lovelycateye:他code裡面的this指到的根本就不是context 05/04 22:56
kewang:是打錯字了吧 import android.app.AlertDialog 05/05 00:34
badhabit:第一步 import android.app.AlertDialog; 05/05 20:58
badhabit:第二步 new AlertDialog.Builder(Bmi.this) 05/05 20:59
sillysmile:樓上謝謝!! 成功了!! 05/06 22:59