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

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

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

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

    <tfoot id='tZ0Y7'></tfoot>

      <bdo id='tZ0Y7'></bdo><ul id='tZ0Y7'></ul>
    1. 如何使用 xml 布局獲取對在自定義對話框中創建的

      How to get reference to a Button created in a custom Dialog, using a xml layout?(如何使用 xml 布局獲取對在自定義對話框中創建的按鈕的引用?)
              <tbody id='zIV02'></tbody>

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

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

                本文介紹了如何使用 xml 布局獲取對在自定義對話框中創建的按鈕的引用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一個活動,用戶可以在其中更新特定信息,點擊標簽附近的按鈕.這個按鈕會觸發一個對話框,其中我有一些字段來獲取用戶輸入和一個按鈕來完成編輯.

                I have an Activity in which user can update a specific information clicking in a button near a label. This buttons than triggers a Dialog where I have some fields to get user input and a button to finish editing.

                我的問題是我無法在對話框特定的 xml 布局中獲得對按鈕聲明的引用.按鈕引用返回 null.按照一些代碼片段來說明.

                My problem is that I am not able to get a reference to the button declare in the dialog specific xml layout. The button reference returns null. Follow some code snippet to ilustrate.

                觸發事件以構建對話框的按鈕在活動中聲明為實例變量,如下所示:

                Button which fires the event to build the dialog is declared as a instance variable in the activity as follows:

                private Button bConfigurarCarro;
                

                比onCreate方法:

                than onCreate method:

                bConfigurarCarro = (Button)findViewById(R.id.bConfigurarCarro);
                 bConfigurarCarro.setOnClickListener(configuraCarroListener);
                

                這會正確觸發事件以創建對話框:

                this correctly fires the event to create the dialog:

                protected OnClickListener configuraCarroListener = new OnClickListener(){
                public void onClick(View v) {
                showDialog(CARRO_DIALOG_ID);
                Log.d(TAG, "Executando evento do bot?o de configura??o de carro no abastecimento.");
                            }
                        };
                

                比創建對話框重寫 onCreateDialog 方法是這樣的:

                than to create the dialog Overrides onCreateDialog method like this:

                @Override
                protected Dialog onCreateDialog(int id) {
                  switch (id) {
                    case TIME_DIALOG_ID:
                        return new TimePickerDialog(this, mTimeSetListener, hora, minuto, false);
                    case DATE_DIALOG_ID:
                        return new DatePickerDialog(this, mDateSetListener, ano, mes, dia);
                    case CARRO_DIALOG_ID:
                        Log.d(TAG, "Criando dialog de cadastro de carro.");
                        dialogCarro = new Dialog(this);
                        dialogCarro.setContentView(R.layout.novo_carro_dialog);
                        bSalvarCarro = (Button)findViewById(R.id.botaoSalvarCarro);
                        bSalvarCarro.setOnClickListener(salvarCarroListener);
                        dialogCarro.setTitle("Carro");
                        dialogCarro.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
                        Log.d(TAG, "Dialog de cadastro de carro criado retornando...");
                        return dialogCarro;
                    }
                        return null;
                }
                

                NullPointer 觸發的特定行是在嘗試獲取上面的 Button 引用后,我嘗試 setOnClickListener..

                The specific line where the NullPointer triggers is the one where after trying to get Button reference above, I than try to setOnClickListener..

                bSalvarCarro = (Button)findViewById(R.id.botaoSalvarCarro);
                bSalvarCarro.setOnClickListener(salvarCarroListener);
                

                bSalvarCarro 為空.

                the bSalvarCarro is null.

                我嘗試使用代碼行在上面設置的對話框的 xml 布局:

                The xml layout for the Dialog which I try to set above using the line of code:

                dialogCarro.setContentView(R.layout.novo_carro_dialog);
                

                是這個嗎(novo_carro_dialog.xml):

                Is this one(novo_carro_dialog.xml):

                <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
                        android:layout_width="fill_parent" android:layout_height="fill_parent">
                            <TableRow>
                                <TextView android:id="@+id/marcaCarro"
                                    android:layout_width="wrap_content" android:layout_height="wrap_content" 
                                    android:text="@string/marcaCarro"/>
                                <EditText android:id="@+id/tMarcaCarro" android:singleLine="true" android:layout_width="fill_parent"
                                android:layout_height="wrap_content" android:width="130px"/>
                            </TableRow>
                            <TableRow>
                                <TextView android:id="@+id/nomeCarro"
                                    android:layout_width="wrap_content" android:layout_height="wrap_content" 
                                    android:text="@string/nomeCarro"/>
                                <EditText android:id="@+id/tNomeCarro" android:singleLine="true" android:layout_width="fill_parent"
                                android:layout_height="wrap_content"/>
                            </TableRow>
                            <TableRow>
                                <TextView android:id="@+id/anoCarro"
                                    android:layout_width="wrap_content" android:layout_height="wrap_content" 
                                    android:text="@string/anoCarro"/>
                                <EditText android:id="@+id/tAnoCarro" android:singleLine="true" android:layout_width="fill_parent"
                                android:numeric="integer" android:maxLength="4" android:layout_height="wrap_content" />
                            </TableRow>
                            <TableRow>
                                <TextView android:id="@+id/modeloCarro"
                                    android:layout_width="wrap_content" android:layout_height="wrap_content" 
                                    android:text="@string/modeloCarro"/>
                                <EditText android:id="@+id/tModeloCarro" android:singleLine="true" android:layout_width="fill_parent"
                                android:layout_height="wrap_content" />
                            </TableRow>
                            <Button android:id="@+id/botaoSalvarCarro" android:layout_width="wrap_content"
                                    android:layout_height="wrap_content" android:text="@string/bSalvarCarro" />
                </TableLayout>
                

                如您所見,Button 是用 id botaoSalvarCarro 聲明的,但嘗試獲取對它的引用會返回 null.我對此有點困惑,好像我取出設置偵聽器的行,對話框正確顯示,所以.如何正確獲取對該按鈕的引用?

                As you can see the Button is declared with the id botaoSalvarCarro, but trying to get a reference to it returns null. I am a bit confused by this as if I take out the line which sets the listener the dialog is correctly showed, so. How do I get the reference to this button correctly?

                推薦答案

                dialogCarro = new Dialog(this);
                dialogCarro.setContentView(R.layout.novo_carro_dialog);
                bSalvarCarro = (Button)dialogCarro.findViewById(R.id.botaoSalvarCarro);
                

                這篇關于如何使用 xml 布局獲取對在自定義對話框中創建的按鈕的引用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                • <legend id='8T574'><style id='8T574'><dir id='8T574'><q id='8T574'></q></dir></style></legend>

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

                          主站蜘蛛池模板: 欧美九九 | 国产成人精品一区二区三区四区 | 久久久久国产精品 | 一道本视频 | 亚洲色图网址 | 成人av播放| 一区二区三区欧美在线观看 | 欧美aaaa视频| 久久久久国产精品人 | 91se在线 | 久久亚洲一区 | 91大神xh98xh系列全部 | 一区观看 | 狠狠操狠狠操 | 美女黄色在线观看 | 日韩中文一区 | 免费观看色 | 中国大陆高清aⅴ毛片 | 91精品久久久久久综合五月天 | 中文字幕成人av | 国产伦一区二区三区四区 | 日韩国产精品一区二区三区 | 国产一区二区在线视频 | 久久久国产精品视频 | 国产在线一区二区三区 | 色www精品视频在线观看 | 午夜a v电影 | 日韩高清中文字幕 | 欧美日韩一区二区三区四区五区 | 国产一区二区三区四区 | www免费视频 | 国产精品美女久久久久久免费 | 欧美一区二区三区在线观看视频 | 亚洲视频一区 | 亚洲第一福利视频 | 欧美在线精品一区 | 看av网址| 亚洲精品免费视频 | aaaa日韩| 国产精品一区二区日韩 | 视频一区二区三区四区五区 |