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

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

    2. <small id='juSrX'></small><noframes id='juSrX'>

    3. <tfoot id='juSrX'></tfoot>
        <bdo id='juSrX'></bdo><ul id='juSrX'></ul>

      從 Android 的視圖中打開帶有文本輸入的對話框

      Opening a Dialog with text input from within a View in Android(從 Android 的視圖中打開帶有文本輸入的對話框)
      • <i id='sNxk8'><tr id='sNxk8'><dt id='sNxk8'><q id='sNxk8'><span id='sNxk8'><b id='sNxk8'><form id='sNxk8'><ins id='sNxk8'></ins><ul id='sNxk8'></ul><sub id='sNxk8'></sub></form><legend id='sNxk8'></legend><bdo id='sNxk8'><pre id='sNxk8'><center id='sNxk8'></center></pre></bdo></b><th id='sNxk8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sNxk8'><tfoot id='sNxk8'></tfoot><dl id='sNxk8'><fieldset id='sNxk8'></fieldset></dl></div>

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

        <tfoot id='sNxk8'></tfoot>
          <legend id='sNxk8'><style id='sNxk8'><dir id='sNxk8'><q id='sNxk8'></q></dir></style></legend>
            <bdo id='sNxk8'></bdo><ul id='sNxk8'></ul>
                <tbody id='sNxk8'></tbody>
                本文介紹了從 Android 的視圖中打開帶有文本輸入的對話框的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一個基于 SurfaceHolder 的帶有 View 的應用(類似于 Lunar Lander 教程).整個 GUI 繪制在畫布上,我希望能夠在給定時刻使用自定義布局對話框提示用戶文本輸入,然后使用標準程序處理并呈現到畫布上.

                I have an app with a View based on the SurfaceHolder (similar to the Lunar Lander tutorial). The whole GUI is drawn on a canvas, and I want to be able to prompt for user text input at a given moment using a custom layout Dialog, that is then taken care of and rendered to the canvas using standard procedure.

                然而,我的問題是,似乎最好的做法是從活動中打開對話框.這也沒有問題,因為我認為我可能會創建一個處理程序,然后將其傳遞給視圖,視圖又可以使用它將消息從視圖中的 GUI 線程傳遞到 Activity,進而可以獲取輸入,并發送回復等.

                My problem, however, is that it seems that best practice is to open Dialogs from the Activity. This is no problem either, since i thought i might create a Handler and then pass it to the View that could in turn use it to pass Messages from the GUI thread in the View on to the Activity, that in turn could fetch the input, and send a reply back, etc.

                問題是,在我調用包含整個應用程序的 setContentView(R.layout.main) 之后,我想調用 MyAppView mMyAppView = (MyAppView) findViewById(R.id.app_view_id).

                Problem is, after I call setContentView(R.layout.main), which contains the whole app, i want to call MyAppView mMyAppView = (MyAppView) findViewById(R.id.app_view_id).

                此調用返回 null.

                這里認為最佳做法是什么?我找不到任何好的示例,而且 API 正在出現,嗯,不多.

                What is considered to be best practice here? I can't find any good examples and the API is turning up, well, not much.

                如果有任何幫助,我將不勝感激.

                I would appreciate any help here.

                推薦答案

                創建一個以對話框為主題的活動以顯示在您當前的活動上.

                Create a dialog themed activity to display over your current activity.

                public class TextEntryActivity extends Activity {
                    private EditText et;
                
                    /*
                     * (non-Javadoc)
                     * @see android.app.Activity#onCreate(android.os.Bundle)
                     */
                    @Override
                    protected void onCreate(Bundle savedInstanceState) {
                        super.onCreate(savedInstanceState);
                
                        setContentView(R.layout.activity_text_entry);
                        getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
                                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
                        // title
                        try {
                            String s = getIntent().getExtras().getString("title");
                            if (s.length() > 0) {
                                this.setTitle(s);
                            }
                        } catch (Exception e) {
                        }
                        // value
                
                        try {
                            et = ((EditText) findViewById(R.id.txtValue));
                            et.setText(getIntent().getExtras().getString("value"));
                        } catch (Exception e) {
                        }
                        // button
                        ((Button) findViewById(R.id.btnDone)).setOnClickListener(new OnClickListener() {
                
                            @Override
                            public void onClick(View v) {
                                executeDone();
                            }
                        });
                    }
                
                    /* (non-Javadoc)
                     * @see android.app.Activity#onBackPressed()
                     */
                    @Override
                    public void onBackPressed() {
                        executeDone();
                        super.onBackPressed();
                    }
                
                    /**
                     *
                     */
                    private void executeDone() {
                        Intent resultIntent = new Intent();
                        resultIntent.putExtra("value", TextEntryActivity.this.et.getText().toString());
                        setResult(Activity.RESULT_OK, resultIntent);
                        finish();
                    }
                
                
                }
                

                發布者:

                Intent foo = new Intent(this, TextEntryActivity.class);
                foo.putExtra("value", "old value to edit");
                this.startActivityForResult(foo, EDIT_ACTION);
                

                然后在 onActivityResult

                protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                        switch (requestCode) {
                            case EDIT_ACTION:
                                try {
                                    String value = data.getStringExtra("value");
                                    if (value != null && value.length() > 0) {
                                        //do something with value
                                    }
                                } catch (Exception e) {
                                }
                                break;
                            default:
                                break;
                        }
                    }
                

                清單定義為:

                <activity
                            android:name=".utils.TextEntryActivity"
                            android:label="Type in the value"
                            android:theme="@android:style/Theme.Dialog" />
                

                這篇關于從 Android 的視圖中打開帶有文本輸入的對話框的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='SSJsw'></bdo><ul id='SSJsw'></ul>
                        <tbody id='SSJsw'></tbody>
                    • <legend id='SSJsw'><style id='SSJsw'><dir id='SSJsw'><q id='SSJsw'></q></dir></style></legend>

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

                    • <tfoot id='SSJsw'></tfoot>

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

                        1. 主站蜘蛛池模板: 国产精品伦理一区 | 在线播放中文字幕 | 国产精品日韩 | 一级做受毛片免费大片 | 国产午夜精品视频 | 日韩综合网 | 婷婷狠狠| 精品在线免费观看视频 | 国产成人短视频在线观看 | 97伦理电影 | 国产乱码一二三区精品 | 欧美精品1区 | 国产三级电影网站 | 一区二区三区韩国 | 日本久久精 | 91视频91| 高清av电影| 日韩精品一区中文字幕 | 婷婷在线网站 | 国产精品日产欧美久久久久 | 精精国产xxxx视频在线播放7 | 国产精品久久久久久久久久久久 | 国产成人在线视频免费观看 | 综合网视频 | 精品伊人 | 亚洲精品视频在线看 | 国产成人精品视频 | 黄色av免费网站 | 日本精品一区二区三区在线观看视频 | 女同久久另类99精品国产 | 日本一区二区影视 | 91超碰在线观看 | 国产精品自产拍 | 国产精品五月天 | 免费精品国产 | 一区二区亚洲 | 欧美激情国产精品 | 国产精品美女久久久久aⅴ国产馆 | 久久久成人一区二区免费影院 | 成人av播放 | 亚洲一区二区三区四区五区午夜 |