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

    <tfoot id='RXC8A'></tfoot>
  1. <small id='RXC8A'></small><noframes id='RXC8A'>

    • <bdo id='RXC8A'></bdo><ul id='RXC8A'></ul>
    1. <i id='RXC8A'><tr id='RXC8A'><dt id='RXC8A'><q id='RXC8A'><span id='RXC8A'><b id='RXC8A'><form id='RXC8A'><ins id='RXC8A'></ins><ul id='RXC8A'></ul><sub id='RXC8A'></sub></form><legend id='RXC8A'></legend><bdo id='RXC8A'><pre id='RXC8A'><center id='RXC8A'></center></pre></bdo></b><th id='RXC8A'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RXC8A'><tfoot id='RXC8A'></tfoot><dl id='RXC8A'><fieldset id='RXC8A'></fieldset></dl></div>
      <legend id='RXC8A'><style id='RXC8A'><dir id='RXC8A'><q id='RXC8A'></q></dir></style></legend>
    2. onOptionsItemSelected android中的警報(bào)對(duì)話(huà)框

      Alert Dialog from within onOptionsItemSelected android(onOptionsItemSelected android中的警報(bào)對(duì)話(huà)框)
    3. <small id='cVjoW'></small><noframes id='cVjoW'>

        1. <tfoot id='cVjoW'></tfoot>
          <legend id='cVjoW'><style id='cVjoW'><dir id='cVjoW'><q id='cVjoW'></q></dir></style></legend>

              <tbody id='cVjoW'></tbody>

              • <bdo id='cVjoW'></bdo><ul id='cVjoW'></ul>
                <i id='cVjoW'><tr id='cVjoW'><dt id='cVjoW'><q id='cVjoW'><span id='cVjoW'><b id='cVjoW'><form id='cVjoW'><ins id='cVjoW'></ins><ul id='cVjoW'></ul><sub id='cVjoW'></sub></form><legend id='cVjoW'></legend><bdo id='cVjoW'><pre id='cVjoW'><center id='cVjoW'></center></pre></bdo></b><th id='cVjoW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cVjoW'><tfoot id='cVjoW'></tfoot><dl id='cVjoW'><fieldset id='cVjoW'></fieldset></dl></div>
                本文介紹了onOptionsItemSelected android中的警報(bào)對(duì)話(huà)框的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                當(dāng)我的一個(gè) OptionsMenuItems 被點(diǎn)擊時(shí),我試圖打開(kāi)一個(gè)警告對(duì)話(huà)框.如果用戶(hù)單擊是"則繼續(xù)操作,如果單擊否"則取消.我只是不知道如何編寫(xiě)代碼.這就是我所擁有的:

                I'm trying to bring up an alert dialog box when one of my OptionsMenuItems is clicked. Proceed with operation if user clicks "yes", cancels if clicks no. I just don't know how to do the code. This is what I have:

                @Override
                public boolean onOptionsItemSelected(MenuItem item)
                { 
                
                    switch (item.getItemId()) { 
                    case R.id.exit:
                        this.finish();
                        return true;
                    case R.id.about:
                        Intent i = new Intent(this, AboutActivity.class);
                        this.startActivity(i);
                    case R.id.skip:
                        AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
                
                            // set the message to display
                            alertbox.setMessage("The yoga pose will be skipped from now on!").show();
                           alertbox.setCancelable(true);
                           alertbox.setNegativeButton("no").setPositiveButton("OK", new DialogClicklistener() { 
                
                             // click listener on the alert box
                            public boolean onClick(DialogInterface arg0, int arg1) {
                                // the button was clicked
                                boolean success = myDbHelper.setSkip(PoseID);
                                SetImageView2(myDbHelper);
                                return success;
                              }
                
                           });
                
                           // add a neutral button to the alert box and assign a click listener
                           alertbox.setCancelable(true).set(onCancelListener) {
                
                              // click listener on the alert box
                               public boolean onClick(DialogInterface arg0, int arg1) {
                                // the button was clicked
                
                              }
                           });
                           // show it
                           alertbox.show();
                
                     default: 
                            return super.onOptionsItemSelected(item);
                    }
                }
                

                推薦答案

                以下內(nèi)容直接來(lái)自我目前正在開(kāi)發(fā)的應(yīng)用程序.它會(huì)彈出一個(gè) AlertDialog,然后將用戶(hù)帶到不同的活動(dòng)(在他們輸入密碼之后).如果我能澄清任何事情,請(qǐng)告訴我.

                The following is directly from the app I'm currently working on. It brings up an AlertDialog which then takes the user to a different activity (after they enter a password). Please let me know if I can clarify anything about it.

                現(xiàn)在包括整個(gè)方法.

                @Override
                public boolean onOptionsItemSelected(MenuItem item) { 
                    LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
                    final int menuItem = item.getItemId();
                    if ((menuItem == R.id.survey) || (menuItem == R.id.syncMode)) {
                        View layout = inflater.inflate(R.layout.survey_password_dialog, (ViewGroup) findViewById(R.id.layout_root));
                        final EditText password = (EditText) layout.findViewById(R.id.passwordText);
                        AlertDialog.Builder builder = new AlertDialog.Builder(this);            
                        builder.setView(layout)
                        .setCancelable(false)
                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int id) {   
                            }
                        })
                        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });
                        final AlertDialog alertDialog = builder.create();
                        alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
                            @Override
                            public void onShow(DialogInterface dialog) {
                                Button b = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
                                b.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (password.getText().toString().equalsIgnoreCase("the_password")) {
                                            if (menuItem == R.id.survey) {
                                                Intent intent = new Intent(AsthmaAppActivity.this, SurveyActivity.class);
                                                startActivity(intent);
                                                alertDialog.dismiss();
                                            }
                                            else { //(menuItem == R.id.syncMode) 
                                                startActivity(new Intent(AsthmaAppActivity.this, SyncMode.class));
                                                alertDialog.dismiss();
                                            }
                                        }
                                        else Toast.makeText(AsthmaAppActivity.this, "Password incorrect", Toast.LENGTH_LONG).show();
                                    }
                                });
                            }
                        });
                        alertDialog.getWindow().setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                        alertDialog.show();
                    }
                    else {  //dialog for setting application parameters "on the fly" for application testing
                        View layout = inflater.inflate(R.layout.parameter_change, (ViewGroup) findViewById(R.id.layout_root));
                        final EditText parameter = (EditText) layout.findViewById(R.id.parameterText);
                        AlertDialog.Builder builder = new AlertDialog.Builder(this);
                        builder.setView(layout)
                        .setCancelable(false)
                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {  
                                String parameterString = parameter.getText().toString();
                                if(parameterString == null || parameterString.isEmpty()) {
                                    testParam = 0.0;
                                } 
                                else {
                                    testParam = Double.parseDouble(parameterString);
                                }
                            }
                        })
                        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        })
                        .show();
                    }
                    return(super.onOptionsItemSelected(item));
                } 
                

                這篇關(guān)于onOptionsItemSelected android中的警報(bào)對(duì)話(huà)框的文章就介紹到這了,希望我們推薦的答案對(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 獲取用戶(hù)的當(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)
                  <legend id='Ts5Da'><style id='Ts5Da'><dir id='Ts5Da'><q id='Ts5Da'></q></dir></style></legend>

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

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

                        • 主站蜘蛛池模板: 一区二区中文 | 亚洲精品一二三区 | 成人免费视频网 | 成人视屏在线观看 | 日韩免费视频一区二区 | 欧美成人精品欧美一级 | 中文字幕福利视频 | 久综合 | 日本一区二区三区免费观看 | a国产一区二区免费入口 | 国内精品视频在线观看 | 精品日韩在线 | 国产欧美日韩在线 | 国精久久 | 粉嫩一区二区三区国产精品 | 亚洲一二三在线观看 | 国产日产精品一区二区三区四区 | 午夜av一区二区 | 日本久草| 天天曰夜夜操 | 黄色一级免费 | 日韩精品一区二区三区久久 | 欧美久久免费观看 | 天天草天天操 | 亚洲国产高清免费 | www.久久久久久久久久久 | 日韩欧美三级电影在线观看 | 色婷婷av一区二区三区软件 | 欧美二级 | 欧美亚州综合 | 亚洲视频在线免费观看 | 羞羞的视频免费观看 | 成人二区| 亚洲免费av一区 | 日本在线中文 | 日韩欧美中文在线 | 国产综合久久 | 久久久久亚洲国产| 日韩成人在线播放 | 久久黄色网 | 中国美女撒尿txxxxx视频 |