久久久久久久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 中的對(duì)話框啟動(dòng) Activity

        How to start an activity from a dialog in Android(如何從 Android 中的對(duì)話框啟動(dòng) 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 中的對(duì)話框啟動(dòng) Activity的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我創(chuàng)建了一個(gè)自定義對(duì)話框,我想在單擊確定"時(shí)開始一個(gè)新活動(dòng).如何獲取上下文以將其設(shè)置為 Intent 構(gòu)造函數(shù)的第一個(gè)參數(shù)?

                  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() 創(chuàng)建意圖,但我不能調(diào)用 startActivity.我應(yīng)該將調(diào)用對(duì)話框的活動(dòng)傳遞給對(duì)話框的構(gòu)造函數(shù)嗎?是否是通過單擊對(duì)話框來啟動(dòng)活動(dòng)的常用方式?

                  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);
                      }
                    }
                  }
                  

                  這篇關(guān)于如何從 Android 中的對(duì)話框啟動(dòng) Activity的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(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(如何檢測位置提供者?GPS 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應(yīng)用啟動(dòng)期間獲取當(dāng)前位置)
                  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>

                          • 主站蜘蛛池模板: 国产精品99久 | 91国内精品 | 国产精品九九九 | 日日夜夜精品视频 | 精品中文视频 | 国产精品免费一区二区三区 | 99re在线播放 | 蜜桃一区二区三区 | 欧美综合国产精品久久丁香 | 天天插天天操 | 成人免费一区二区三区视频网站 | 国产精品久久久久久久久免费相片 | 亚洲精品9999久久久久 | 欧美一区二区在线观看 | 国产日韩欧美在线观看 | 国产日产精品一区二区三区四区 | 成人av一区二区三区 | 日韩国产精品一区二区三区 | 亚洲成人免费 | 亚洲伦理自拍 | 日韩三区在线观看 | 日韩成人免费视频 | 国产三级一区二区三区 | 黄免费在线 | 成人小视频在线免费观看 | 日韩免费福利视频 | 欧美日本高清 | 日韩在线视频免费观看 | 日韩欧美精品在线播放 | 日韩精品一区二区三区视频播放 | 国产欧美一区二区三区久久 | 国产一区二区a | 成人国产精品免费观看 | 91热在线| 午夜av免费 | 日韩成人影院 | 99re热这里只有精品视频 | 欧美日韩在线观看视频 | 久久中文字幕视频 | 一级a性色生活片久久毛片 午夜精品在线观看 | 久久精品欧美一区二区三区不卡 |