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

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

  • <small id='iAxoH'></small><noframes id='iAxoH'>

    <legend id='iAxoH'><style id='iAxoH'><dir id='iAxoH'><q id='iAxoH'></q></dir></style></legend>

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

        僅使用 Context 而不是 Activity 實例顯示對話框

        Show dialog only using Context instead of Activity instance(僅使用 Context 而不是 Activity 實例顯示對話框)
            <i id='PUtxa'><tr id='PUtxa'><dt id='PUtxa'><q id='PUtxa'><span id='PUtxa'><b id='PUtxa'><form id='PUtxa'><ins id='PUtxa'></ins><ul id='PUtxa'></ul><sub id='PUtxa'></sub></form><legend id='PUtxa'></legend><bdo id='PUtxa'><pre id='PUtxa'><center id='PUtxa'></center></pre></bdo></b><th id='PUtxa'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PUtxa'><tfoot id='PUtxa'></tfoot><dl id='PUtxa'><fieldset id='PUtxa'></fieldset></dl></div>
            <tfoot id='PUtxa'></tfoot>

                • <bdo id='PUtxa'></bdo><ul id='PUtxa'></ul>
                    <tbody id='PUtxa'></tbody>
                • <small id='PUtxa'></small><noframes id='PUtxa'>

                  <legend id='PUtxa'><style id='PUtxa'><dir id='PUtxa'><q id='PUtxa'></q></dir></style></legend>
                  本文介紹了僅使用 Context 而不是 Activity 實例顯示對話框的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  如果我使用 Activity 實例,我可以顯示對話框,但是當我使用 Context 或 Application Context 實例時,對話框沒有顯示.

                  I could show dialog if I uses an Activity instance but when I uses Context or Application Context instance Dialog is not showing.

                  AlertDialog.Builder builder = new AlertDialog.Builder(activity);
                              builder.setTitle(title);
                              builder.setMessage(msg);
                  
                              if (null != positiveLabel) {
                                  builder.setPositiveButton(positiveLabel, new DialogInterface.OnClickListener() {
                  
                                      @Override
                                      public void onClick(DialogInterface dialog, int which) {
                  
                                          dialog.cancel();
                                          if (null != listener) {
                                              listener.onOk();
                                          }
                                      }
                                  });
                              }
                  
                              if (null != negativeLable) {
                                  builder.setNegativeButton(negativeLable, new DialogInterface.OnClickListener() {
                  
                                      @Override
                                      public void onClick(DialogInterface dialog, int which) {
                  
                                          dialog.cancel();
                                          if (null != listener) {
                                              listener.onCancel();
                                          }
                                      }
                                  });
                              }
                  
                              builder.create().show();
                  

                  你能不能給我一個解決方案來顯示對話框而不使用 Activity 實例

                  Can you please give me a solution to show dialog without using Activity instance

                  推薦答案

                  這個問題也是我最近遇到的問題,沒有Activity實例就不能創建對話框.getApplicationContext() 調用也不起作用.我這樣做的方法是從一個活動調用創建對話框的方法,并傳遞this",即對該活動的引用作為參數.

                  The problem is something I faced recently too, you cant create a dialog without and activity instance. getApplicationContext() call doesn't work too. The way I did this is to make the call to a method that creates the dialog, from an activity, and pass "this" i.e. the reference to that activity as a parameter.

                  如果您打算重用此代碼,作為可重用組件或作為在多個位置創建對話框的機制,請創建一個基本活動類并在其中包含此方法,并根據需要在子類活動中使用它.

                  If you are going to reuse this code, as a reusable component or as a mechanism to create dialogs at multiple places, create a base activity class and have this method in there, and use it in sub-classed activities as needed.

                  這篇關于僅使用 Context 而不是 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)

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

                            <tbody id='ZSMJf'></tbody>
                          <tfoot id='ZSMJf'></tfoot>
                            <bdo id='ZSMJf'></bdo><ul id='ZSMJf'></ul>
                            主站蜘蛛池模板: 亚洲一区二区在线视频 | 日韩精品在线看 | 久久久99精品免费观看 | 欧美激情久久久 | 亚洲成人精选 | 人人干在线| 久久精品在线播放 | 一区精品国产欧美在线 | 在线国产精品一区 | 欧美性一区二区三区 | 男女深夜网站 | 亚洲精品一区二三区不卡 | 日日干夜夜干 | av天天干 | 日韩视频中文字幕 | 成人三级电影 | av手机在线免费观看 | 亚洲二区在线观看 | 亚洲精品永久免费 | 2022精品国偷自产免费观看 | 日韩一级黄色毛片 | 国产99视频精品免费播放照片 | 国产精品成人一区二区 | 久久久久国产精品午夜一区 | 久久手机视频 | 成人免费在线小视频 | 免费久久网站 | 最新国产精品视频 | 国产在线播放av | 色综合99 | 狠狠操av| 日一区二区| 欧美日韩高清 | 中文字幕日韩一区 | 伊人久久精品一区二区三区 | 国产欧美日韩在线观看 | 午夜精品 | 精品欧美一区二区三区免费观看 | 国内精品99 | 日韩色综合 | 亚洲欧洲一区二区 |