久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='u83Vx'></tfoot>

<small id='u83Vx'></small><noframes id='u83Vx'>

<i id='u83Vx'><tr id='u83Vx'><dt id='u83Vx'><q id='u83Vx'><span id='u83Vx'><b id='u83Vx'><form id='u83Vx'><ins id='u83Vx'></ins><ul id='u83Vx'></ul><sub id='u83Vx'></sub></form><legend id='u83Vx'></legend><bdo id='u83Vx'><pre id='u83Vx'><center id='u83Vx'></center></pre></bdo></b><th id='u83Vx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='u83Vx'><tfoot id='u83Vx'></tfoot><dl id='u83Vx'><fieldset id='u83Vx'></fieldset></dl></div>

    • <bdo id='u83Vx'></bdo><ul id='u83Vx'></ul>
    1. <legend id='u83Vx'><style id='u83Vx'><dir id='u83Vx'><q id='u83Vx'></q></dir></style></legend>

        如何從 Android 中的對話框啟動 Activity

        How to start an activity from a dialog in Android(如何從 Android 中的對話框啟動 Activity)

                <bdo id='cKjAk'></bdo><ul id='cKjAk'></ul>
                  <tfoot id='cKjAk'></tfoot>

                    <tbody id='cKjAk'></tbody>

                1. <i id='cKjAk'><tr id='cKjAk'><dt id='cKjAk'><q id='cKjAk'><span id='cKjAk'><b id='cKjAk'><form id='cKjAk'><ins id='cKjAk'></ins><ul id='cKjAk'></ul><sub id='cKjAk'></sub></form><legend id='cKjAk'></legend><bdo id='cKjAk'><pre id='cKjAk'><center id='cKjAk'></center></pre></bdo></b><th id='cKjAk'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cKjAk'><tfoot id='cKjAk'></tfoot><dl id='cKjAk'><fieldset id='cKjAk'></fieldset></dl></div>

                  <small id='cKjAk'></small><noframes id='cKjAk'>

                  <legend id='cKjAk'><style id='cKjAk'><dir id='cKjAk'><q id='cKjAk'></q></dir></style></legend>
                  本文介紹了如何從 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?

                  public class CustomDialog extends Dialog implements OnClickListener {
                      Button okButton, cancelButton;
                  
                      public CustomDialog(Context context) {      
                          super(context);     
                          setContentView(R.layout.custom_dialog);
                          okButton = (Button) findViewById(R.id.button_ok);
                          okButton.setOnClickListener(this);
                          cancelButton = (Button) findViewById(R.id.button_cancel);
                          cancelButton.setOnClickListener(this);
                      }
                  
                      @Override
                      public void onClick(View v) {       
                          if (v == cancelButton)
                              dismiss();
                          else {
                              Intent i = new Intent(getContext(), ItemSelection.class);
                              startActivity(i); //The method startActivity(Intent) is undefined for the type CustomDialog
                          }
                      }
                  }
                  

                  推薦答案

                  public class CustomDialog extends Dialog implements OnClickListener {
                    Button okButton, cancelButton;
                    Activity mActivity;
                  
                    public CustomDialog(Activity activity) {      
                      super(activity);
                      mActivity = activity;
                      setContentView(R.layout.custom_dialog);
                      okButton = (Button) findViewById(R.id.button_ok);
                      okButton.setOnClickListener(this);
                      cancelButton = (Button) findViewById(R.id.button_cancel);
                      cancelButton.setOnClickListener(this);
                    }
                  
                    @Override
                    public void onClick(View v) {       
                      if (v == cancelButton)
                          dismiss();
                      else {
                          Intent i = new Intent(mActivity, ItemSelection.class);
                          mActivity.startActivity(i);
                      }
                    }
                  }
                  

                  這篇關于如何從 Android 中的對話框啟動 Activity的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                  Get current location during app launch(在應用啟動期間獲取當前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)

                    <bdo id='euIpB'></bdo><ul id='euIpB'></ul>
                      <i id='euIpB'><tr id='euIpB'><dt id='euIpB'><q id='euIpB'><span id='euIpB'><b id='euIpB'><form id='euIpB'><ins id='euIpB'></ins><ul id='euIpB'></ul><sub id='euIpB'></sub></form><legend id='euIpB'></legend><bdo id='euIpB'><pre id='euIpB'><center id='euIpB'></center></pre></bdo></b><th id='euIpB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='euIpB'><tfoot id='euIpB'></tfoot><dl id='euIpB'><fieldset id='euIpB'></fieldset></dl></div>
                        <tbody id='euIpB'></tbody>

                      <small id='euIpB'></small><noframes id='euIpB'>

                          • <tfoot id='euIpB'></tfoot>
                            <legend id='euIpB'><style id='euIpB'><dir id='euIpB'><q id='euIpB'></q></dir></style></legend>

                          • 主站蜘蛛池模板: 91精品国产综合久久久久久 | 亚洲一区二区三区在线视频 | 日韩在线成人 | 午夜国产一级 | 精品乱人伦一区二区三区 | 天天久久 | 在线播放国产一区二区三区 | 欧美a在线| 欧美日韩久久 | 黄色大片在线播放 | 一二三区av | 欧美精品在线视频 | 亚洲交性 | 狠狠影院| 亚洲第一福利网 | 在线国产欧美 | 亚洲精品乱码久久久久久蜜桃91 | 亚洲伊人久久综合 | 国际精品久久 | 国产精品视频在线观看 | 中文字幕一区二区三区精彩视频 | 成人国产在线视频 | 久久99精品国产 | 亚洲国产精品福利 | 免费黄色特级片 | a级黄色毛片免费播放视频 国产精品视频在线观看 | 中文字幕一区二区三区日韩精品 | 国产伦精品一区二区三区四区视频 | 国产欧美在线播放 | 欧美精品久久 | 中文字字幕在线中文乱码范文 | 正在播放国产精品 | 97视频人人澡人人爽 | 综合久久综合久久 | 成人av一区二区亚洲精 | 成人免费视频网站在线观看 | 欧美一级一 | 人人九九精 | 99精品国产一区二区三区 | 久久久久久国产精品免费免费狐狸 | 欧美视频免费在线观看 |