title: How to set spinner item when opening layout in this case?
body: <p>I use this library <a href="https://github.com/orhanobut/dialogplus" rel="nofollow noreferrer">https://github.com/orhanobut/dialogplus</a></p>
  
  <p>When i click a button i will open a dialog layout that include <code>EditText</code> and <code>Spinner</code>.</p>
  
  <p>My problem is i don't know how to set my <code>Spinner</code> item when the dialog layout open. This library make me declare my <code>Spinner</code> under <code>setOnClickListener</code>, because i have to use <code>dialog.getHolderView()</code> to get the view. I think it is the problem, but i don't know how to fix it.</p>
  
  <p>In my code, i must click the <code>Spinner</code> then my spinner item will be added.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public void openSearchLayout() {
      DialogPlus dialog = DialogPlus.newDialog(getActivity())
              .setContentHolder(new ViewHolder(R.layout.search_layout))
              .setGravity(Gravity.TOP)
              .setOnClickListener(new OnClickListener() {
                  @Override
                  public void onClick(DialogPlus dialog, View view) {
  
                      EditText presenterEdit = (EditText) dialog.getHolderView().findViewById(R.id.presenterEdit);
                      final Spinner searchDate = (Spinner) dialog.getHolderView().findViewById(R.id.searchDate);
                      // Clear spinner data
                      dateList.clear();
                      // Set spinner item function
                      showRoute(myJson, searchDate);
                      switch (view.getId()) {
                          case R.id.searchDate:
                              searchDate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                                  @Override
                                  public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                                      // Clear spinner data
                                      arrayList.clear();
                                      // Search the spinner item value list
                                      showDateRoute(myJson, searchDate.getSelectedItem().toString());
                                  }
                                  @Override
                                  public void onNothingSelected(AdapterView&lt;?&gt; parent) {
                                  }
                              });
                              break;
  
                          case R.id.searchButton:
                              String testString = presenterEdit.getText().toString();
                              Toast.makeText(getActivity(), testString, Toast.LENGTH_SHORT).show();
                              break;
                      }
                  }
              })
              .setExpanded(true, 900)  // This will enable the expand feature, (similar to android L share dialog)
              .create();
      dialog.show();
  }
  </code></pre>
  
  <p>Here is my custom layout for dialog:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          android:paddingLeft="16dp"
          android:paddingTop="16dp"&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:text="@string/signUpDate"
              android:textColor="@android:color/black"
              android:textSize="18dp" /&gt;
  
          &lt;Spinner
              android:id="@+id/searchDate"
              android:layout_width="match_parent"
              android:layout_height="38dp"
              android:layout_gravity="center"
              android:layout_marginLeft="24dp"
              android:layout_marginRight="16dp"
              android:background="@drawable/spinner_arrow"
              android:spinnerMode="dropdown"
              android:theme="@style/mySpinnerStyle" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          android:paddingLeft="16dp"
          android:paddingTop="16dp"&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:text="@string/circlePresenter"
              android:textColor="@android:color/black"
              android:textSize="18dp" /&gt;
  
          &lt;EditText
              android:id="@+id/presenterEdit"
              android:layout_width="match_parent"
              android:layout_height="38dp"
              android:layout_gravity="center"
              android:layout_marginLeft="8dp"
              android:layout_marginRight="16dp"
              android:background="@drawable/search_edit"
              android:spinnerMode="dropdown" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;Button
          android:id="@+id/searchButton"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginLeft="16dp"
          android:layout_marginRight="16dp"
          android:layout_marginTop="16dp"
          android:background="@drawable/corner_search"
          android:text="@string/integralDateSearch"
          android:textColor="@android:color/white"
          android:textSize="20dp" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Any help would be appreciated. Thanks in advance.</p>
  
  <p>According to Reaz reply i update like this:</p>
  
  <pre><code>ViewHolder dialogViewHolder = new ViewHolder(R.layout.search_layout);
  LayoutInflater inflater =LayoutInflater.from(getActivity());
  final EditText presenterEdit = (EditText) dialogViewHolder.getView(inflater, null).findViewById(R.id.presenterEdit);
  final Spinner searchDate = (Spinner) dialogViewHolder.getView(inflater, null).findViewById(R.id.searchDate);
  // Clear spinner data
  dateList.clear();
  // Set spinner item function
  showRoute(myJson, searchDate);
  
  DialogPlus dialog = DialogPlus.newDialog(getActivity())
          .setContentHolder(dialogViewHolder)
          //.....
  </code></pre>