本文介紹了如何從 Android 中的對話框啟動 Activity的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我創建了一個自定義對話框,我想在單擊確定"時開始一個新活動.如何獲取上下文以將其設置為 Intent 構造函數的第一個參數?
I created a custom dialog and I'd like to start a new activity when OK is clicked. How can I get the context to set it as first argument of my Intent constructor?
我可以使用 getContext()
創建意圖,但我不能調用 startActivity
.我應該將調用對話框的活動傳遞給對話框的構造函數嗎?是否是通過單擊對話框來啟動活動的常用方式?
I can create the intent using getContext()
, but I can't call startActivity
. Shall I pass the activity calling the dialog to the dialog's constructor? Is it the usual way to start an activity by clicking a dialog?
推薦答案
這篇關于如何從 Android 中的對話框啟動 Activity的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!