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

  • <small id='4x9iU'></small><noframes id='4x9iU'>

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

        <legend id='4x9iU'><style id='4x9iU'><dir id='4x9iU'><q id='4x9iU'></q></dir></style></legend>

      1. Dialog.show() 與 Activity.showDialog()

        Dialog.show() vs. Activity.showDialog()(Dialog.show() 與 Activity.showDialog())

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

          • <small id='0yl6X'></small><noframes id='0yl6X'>

                    <tbody id='0yl6X'></tbody>
                • 本文介紹了Dialog.show() 與 Activity.showDialog()的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  據(jù)我所知,有兩種方法可以從 Activity 中顯示 Dialog.

                  As far as I can tell, there are two ways to show a Dialog from an Activity.

                  1. 創(chuàng)建 Dialog(例如,使用 AlertDialog.Builder),然后調(diào)用新創(chuàng)建的 Dialog 的 show() 方法.
                  2. 調(diào)用 Activity 的 showDialog() 方法,傳入一個(gè) int,它唯一地定義了您想要構(gòu)建的 Dialog 類(lèi)型.然后重寫(xiě) onCreateDialog() 以實(shí)際構(gòu)建 Dialog,Android 將為您顯示它.
                  1. Create the Dialog (for example, using an AlertDialog.Builder), and then call the newly created Dialog's show() method.
                  2. Call the Activity's showDialog() method, passing in an int that uniquely defines what sort of Dialog you want to build. Then override onCreateDialog() to actually build the Dialog, and Android will display it for you.

                  第二種方法似乎是標(biāo)準(zhǔn)做法,但我很好奇我使用哪種方法是否重要.以下是我能想到的:

                  The second method seems to be the standard practice but I'm curious if there is any reason it matters which one I use. Here's all I can come up with:

                  使用Dialog.show

                  1. 如果您需要以某種方式參數(shù)化 Dialog,使用 Activity.showDialog 可能會(huì)有點(diǎn)尷尬,如 這個(gè)問(wèn)題.您可能必須在成員變量中存儲(chǔ)字符串或其他內(nèi)容,以便稍后在 onCreateDialogonPrepareDialog 期間檢索它.
                  2. 創(chuàng)建和修改對(duì)話框的邏輯分布在多個(gè)地方,可能會(huì)使代碼更難閱讀和維護(hù):
                    • 你調(diào)用showDialog()
                    • 的地方
                    • 在被覆蓋的 onCreateDialog 方法中可能很大的 switch 語(yǔ)句中
                    • 在被覆蓋的 onPrepareDialog 方法中可能很大的 switch 語(yǔ)句中
                  1. If you need to parameterize the Dialog in some way, it can be a little awkward to use Activity.showDialog, as described in this question. You may have to store a String or something in a member variable, just so that it can be retrieved moments later during onCreateDialog or onPrepareDialog.
                  2. The logic for creating and modifying the dialog is spread out across a number of places, potentially making the code harder to read and maintain:
                    • The place where you call showDialog()
                    • Inside a potentially large switch statement in the overridden onCreateDialog method
                    • Inside a potentially large switch statement in the overridden onPrepareDialog method

                  使用Activity.showDialog的原因:

                  1. Activity.showDialog 的 API 文檔說(shuō) Dialog 是由 Activity 管理"的,我想這會(huì)帶來(lái)一些好處嗎?但如果你使用 AlertDialog.Builder 也是如此,我認(rèn)為,因?yàn)槟銓?this 作為參數(shù)傳遞給 Builder 的構(gòu)造函數(shù).
                  2. 如果您的 Activity 將多次顯示相同(或非常相似)的 Dialog,則此選項(xiàng)只創(chuàng)建一次,而不是每次都創(chuàng)建一個(gè)新的,從而減少系統(tǒng)分配空間的壓力用于新對(duì)象、垃圾回收等.
                  1. The API docs for Activity.showDialog say that the Dialog is "managed" by the Activity which I suppose provides some benefit? But this is also true if you use the AlertDialog.Builder, I would think, because you pass in this as an argument to the Builder's constructor.
                  2. If your Activity is going to show the same (or a very similar) Dialog several times, this option creates it only once, instead of creating a new one each time, thus putting less strain on the system as far as allocating space for new objects, garbage collection, etc.

                  所以我的問(wèn)題是,決定何時(shí)使用Activity.showDialog和何時(shí)使用Dialog.show的標(biāo)準(zhǔn)是什么,為什么?

                  So my question is, what are the criteria for deciding when to use Activity.showDialog and when to use Dialog.show, and why?

                  推薦答案

                  在我看來(lái)你應(yīng)該更喜歡 showDialog 因?yàn)檫@個(gè)方法會(huì)為你完成大部分工作.例如,您不必?fù)?dān)心更改屏幕方向后會(huì)丟失對(duì)對(duì)話框的引用.它將自動(dòng)重新創(chuàng)建.Dialog.show 更容易出錯(cuò).

                  In my opinion you should prefer showDialog because this method will do most of the work for you. In example You don't have to worry that you will lose reference to your dialog after changing screen orientation. It will be recreated automatically. Dialog.show is much more prone to errors.

                  所以我建議你盡可能使用 showDialog.

                  So I suggest you to use showDialog everywhere you can.

                  這篇關(guān)于Dialog.show() 與 Activity.showDialog()的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當(dāng)前位置)
                  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(如何檢測(cè)位置提供者?GPS 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應(yīng)用啟動(dòng)期間獲取當(dāng)前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)

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

                      <tfoot id='R5ZOk'></tfoot>
                        <bdo id='R5ZOk'></bdo><ul id='R5ZOk'></ul>
                      • <small id='R5ZOk'></small><noframes id='R5ZOk'>

                              <tbody id='R5ZOk'></tbody>
                            主站蜘蛛池模板: 视频一二三区 | 免费午夜电影 | 亚洲一区二区三区在线 | 成在线人视频免费视频 | 成人网址在线观看 | 成人a免费| 婷婷色国产偷v国产偷v小说 | 狠狠干网站 | 国产av毛片 | 欧美黄在线观看 | 羞羞视频免费在线观看 | 国产伦精品一区二区三区在线 | 热久久国产 | 欧美成人性生活 | 国产精品视频久久久 | 亚洲欧美视频一区 | av日韩在线播放 | 欧美精品区| 久久av一区| 欧美亚洲免费 | 日韩免费av网站 | 99精品视频在线 | 草草影院ccyy| 中文字幕亚洲精品 | 国产在线一| 五月天天丁香婷婷在线中 | 久久亚洲美女 | 亚洲男人天堂 | 在线午夜| 国产成人免费在线观看 | 欧美久久久久久 | 国产一区二区三区 | 国产精品一区二区在线 | 亚洲精选一区二区 | 精品在线一区 | 亚洲色图插插插 | 精品久久99 | 欧美a级成人淫片免费看 | 久久精品视频免费看 | 亚洲综合在线网 | 久草网站 |