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

    <legend id='vWBSo'><style id='vWBSo'><dir id='vWBSo'><q id='vWBSo'></q></dir></style></legend>
      <bdo id='vWBSo'></bdo><ul id='vWBSo'></ul>

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

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

        Android 警報對話框無法找到視圖

        Android Alert Dialog unable to find view(Android 警報對話框無法找到視圖)

              <tbody id='hFn7O'></tbody>

          • <small id='hFn7O'></small><noframes id='hFn7O'>

            <legend id='hFn7O'><style id='hFn7O'><dir id='hFn7O'><q id='hFn7O'></q></dir></style></legend>
              • <bdo id='hFn7O'></bdo><ul id='hFn7O'></ul>

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

                  <tfoot id='hFn7O'></tfoot>
                  本文介紹了Android 警報對話框無法找到視圖的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我無法讓 AlertDialog 將文本傳遞回調(diào)用它的活動.問題似乎是調(diào)用 findViewByID 時找不到正確的 EditText,但我是 Android 新手,不知道為什么會這樣.

                  I'm having trouble getting an AlertDialog to pass text back to the activity that calls it. It seems the issue is that it fails to find the proper EditText when calling findViewByID, but I'm new to Android and don't know why that may be.

                  代碼如下:

                  public class ModifyDialogFragment extends DialogFragment {
                  
                  /* The activity that creates an instance of this dialog fragment must
                   * implement this interface in order to receive event callbacks.
                   * Each method passes the DialogFragment in case the host needs to query it. */
                  public interface MDialogListener {
                      public void onMDialogPositiveClick(String newValue);
                  }
                  
                  // Use this instance of the interface to deliver action events
                  MDialogListener mListener;
                  
                  String mEntryName = "";
                  EditText mEditText;
                  
                  @Override
                  public Dialog onCreateDialog(Bundle savedInstanceState) {
                      // Use the Builder class for convenient dialog construction
                      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                  
                      LayoutInflater inflater = getActivity().getLayoutInflater();
                  
                      final View modifyView = inflater.inflate(R.layout.modify_dialog, null);
                  
                      builder.setView(modifyView);
                  
                      final EditText editText = (EditText) getActivity().findViewById(R.id.modificationText);
                  
                  
                  
                             builder.setPositiveButton(R.string.modify, new DialogInterface.OnClickListener() {
                                 public void onClick(DialogInterface dialog, int id) {
                                     mListener.onMDialogPositiveClick(editText.getText().toString());
                                 }
                             });
                             builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                                 public void onClick(DialogInterface dialog, int id) {
                                     // User cancelled the dialog
                                 }
                             });
                  
                      // Create the AlertDialog object and return it
                      return builder.create();
                  }
                  
                  // Override the Fragment.onAttach() method to instantiate the ModifyDeleteDialogListener
                  @Override
                  public void onAttach(Activity activity) {
                      super.onAttach(activity);
                      // Verify that the host activity implements the callback interface
                      try {
                          // Instantiate the MDDialogListener so we can send events to the host
                          mListener = (MDialogListener) activity;
                      } catch (ClassCastException e) {
                          // The activity doesn't implement the interface, throw exception
                          throw new ClassCastException(activity.toString()
                                  + " must implement MDialogListener");
                      }
                  }
                  

                  以及對應(yīng)的 modify_dialog.xml:

                  And the corresponding modify_dialog.xml:

                  <?xml version="1.0" encoding="utf-8"?>
                  
                  <EditText xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:tools="http://schemas.android.com/tools"
                      android:id="@+id/modificationText"
                      android:inputType="text"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="16dp"
                      android:layout_marginLeft="4dp"
                      android:layout_marginRight="4dp"
                      android:layout_marginBottom="4dp"/>
                  

                  為什么沒有找到editText?我可以做些什么來使這項工作按預(yù)期工作,將新字符串傳遞回活動?

                  Why isn't the editText being found? What can I do to make this work as intended, passing the new string back to the activity?

                  推薦答案

                  改變

                  final EditText editText = (EditText) getActivity().findViewById(R.id.modificationText);
                  

                  final EditText editText = (EditText) modifyView.findViewById(R.id.modificationText);
                  

                  您的 EditText 位于 modify_dialog.xml 中,因此您需要使用該 layout 膨脹的變量(此處為 modifyView) 來查找 id 而不是 getActivty() 將查找的 layout.

                  Your EditText lives in modify_dialog.xml so you need to use the variable that was inflated with that layout (here modifyView) to find the id not the layout that getActivty() will look in.

                  這篇關(guān)于Android 警報對話框無法找到視圖的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個隨機打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲為 int?)
                  <legend id='utjzA'><style id='utjzA'><dir id='utjzA'><q id='utjzA'></q></dir></style></legend><tfoot id='utjzA'></tfoot>

                    • <bdo id='utjzA'></bdo><ul id='utjzA'></ul>

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

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

                              <tbody id='utjzA'></tbody>
                            主站蜘蛛池模板: av在线免费观看网站 | 韩国主播午夜大尺度福利 | 日皮视频免费 | 国产福利在线看 | 国产精品亚洲综合 | 久久毛片网站 | 在线精品一区 | 国产视频三区 | 国产精品久久久久久久久久久久午夜片 | 国产成人在线观看免费 | 午夜不卡一区二区 | 亚洲一区二区三区免费视频 | 一区二区电影 | 二区中文字幕 | 欧美精品乱码久久久久久按摩 | www九色| 国产精品一区二区久久精品爱微奶 | 国产激情视频在线 | 日日爽 | 日韩免费视频一区二区 | 91精品国产综合久久婷婷香蕉 | 国产精品99 | 亚洲欧美视频 | 久久精品中文字幕 | 亚洲国产中文字幕 | 精品在线免费观看视频 | 成人a视频在线观看 | 成人天堂 | 欧美一区永久视频免费观看 | 成人精品 | 九九九视频在线 | 久久久久久久国产 | 国产精品日韩欧美一区二区三区 | 亚洲精品第一 | 亚洲九九精品 | 中文字幕日韩欧美一区二区三区 | 精品视频一区二区三区在线观看 | 天天av天天好逼 | av一区二区三区四区 | 精品欧美一区二区三区久久久 | 国产综合久久 |