title: Soft keyboard not showing in custom dialog fragment
body: <p>I have custom dialog fragment with view pager in it, in view pager has an edit text. When custom dialog fragment showing, the edit text has focus but soft keyboard not showing for input.</p>
  
  <p>xml layout of dialog</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:htdu87="http://schemas.android.com/apk/res/com.htdu87.ekaraoke"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:background="@color/background_app" &gt;
  
      &lt;!-- &lt;com.htdu87.ekaraoke.objects.LikeComment 
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/htdu87_like_comment"/&gt; --&gt;
  
      &lt;com.htdu87.ekaraoke.classes.MyViewPager 
          android:layout_width="match_parent"
          android:layout_height="300dp"
          android:id="@+id/view_pager"
          htdu87:allow_sweep="true"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>java code</p>
  
  <pre><code>package com.htdu87.ekaraoke.classes;
  
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.ParseException;
  import org.apache.http.client.ClientProtocolException;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.util.EntityUtils;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.app.AlertDialog;
  import android.app.Dialog;
  import android.content.Context;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.support.v4.app.DialogFragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.View.OnFocusChangeListener;
  import android.view.WindowManager;
  import android.view.inputmethod.InputMethodManager;
  import android.widget.ArrayAdapter;
  import android.widget.EditText;
  import android.widget.ImageButton;
  import android.widget.LinearLayout;
  import android.widget.ListView;
  
  import com.htdu87.ekaraoke.R;
  import com.htdu87.ekaraoke.adapters.ViewPagerAdapter;
  import com.htdu87.ekaraoke.configs.AppConfig;
  
  public class LikeCommentDialogFragment extends DialogFragment {
      private long postId;
      private final String COMMENT = "Comment";
      private final String LIKE = "Like";
      private ListView lstComment;
      private ListView lstLike;
      private ImageButton btnPos;
      private EditText txtComment;
      private ArrayAdapter&lt;String&gt; adapterComment;
  
      public LikeCommentDialogFragment(){
  
      }
  
  
      public void setPostId(long id){
          postId = id;
      }
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          LayoutInflater inflater = getActivity().getLayoutInflater();
          View likeCommentDlg = inflater.inflate(R.layout.like_comment_dialog, null); 
  
          MyViewPager viewPager = (MyViewPager)likeCommentDlg.findViewById(R.id.view_pager);
  
          MyFragment frg = new MyFragment();
          frg.setViewResourceId(R.layout.comment);
          getActivity().getSupportFragmentManager().beginTransaction().add(frg, COMMENT).commit();
  
          frg = new MyFragment();
          frg.setViewResourceId(R.layout.like);
          getActivity().getSupportFragmentManager().beginTransaction().add(frg, LIKE).commit();
  
          ViewPagerAdapter pagerAdapter = new ViewPagerAdapter(getActivity(), getActivity().getSupportFragmentManager(), new String[]{COMMENT, LIKE});
          viewPager.setAdapter(pagerAdapter);
  
          new LoadComment().execute();
  
          AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
          builder.setView(likeCommentDlg);
          Dialog d = builder.create();
          d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
          d.setCanceledOnTouchOutside(false);
          return d;
      }
  
      private class LoadComment extends AsyncTask&lt;Void, Void, Integer&gt;{
          private List&lt;String&gt; data;
  
          @Override
          protected Integer doInBackground(Void... arg0) {
              // TODO Auto-generated method stub
              String url = AppConfig.SERVER_URL + "load_comment.php?postid="+postId+"&amp;tokent="+AppConfig.TOKENT;
              DefaultHttpClient httpClient = new DefaultHttpClient();
              HttpGet httpGet = new HttpGet(url);
              try {
                  HttpResponse httpResponse = httpClient.execute(httpGet);
                  if(httpResponse.getStatusLine().getStatusCode() == 200){
                      if(!httpResponse.getFirstHeader("Content-Type").getValue().equals("application/json; charset=utf8"))
                          return -1;
                      HttpEntity httpEntity = httpResponse.getEntity();
                      JSONObject jsonObj = new JSONObject(EntityUtils.toString(httpEntity));
                      JSONArray comments = jsonObj.getJSONArray("comments");
                      int count = comments.length();
                      data = new ArrayList&lt;String&gt;();
                      for(int i = 0; i &lt; count; i++){
                          JSONObject commentObj = comments.getJSONObject(i);
                          JSONObject comment = commentObj.getJSONObject("comment");
                          data.add(comment.getString("commentcontent"));
                      }
                      return 0;
                  }
                  return -2;
              } catch (ClientProtocolException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (ParseException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (JSONException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              return -3;
          }
  
          @Override
          protected void onPostExecute(Integer result) {
              // TODO Auto-generated method stub
              super.onPostExecute(result);
              View v = getActivity().getSupportFragmentManager().findFragmentByTag(COMMENT).getView();
              lstComment = (ListView)v.findViewById(R.id.lst_comment);
              txtComment = (EditText)v.findViewById(R.id.txt_comment);
  
              btnPos = (ImageButton)v.findViewById(R.id.btn_post_comment);
              //btnPos.setOnClickListener(LikeComment.this);
              LinearLayout layLoading = (LinearLayout)v.findViewById(R.id.lay_loading);
  
              adapterComment = new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.simple_list_item_1, data);
              lstComment.setAdapter(adapterComment);
              layLoading.setVisibility(View.GONE);
  
              txtComment.requestFocus();
              //InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
              //imm.showSoftInput(txtComment, 0);
          }
      }
  }
  </code></pre>
  
  <p>xml containt edit text</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:padding="5dp" &gt;
  
      &lt;ListView 
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/lst_comment"
          android:layout_above="@+id/lay_write_comment"/&gt;
  
      &lt;LinearLayout 
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:orientation="horizontal"
          android:layout_marginTop="5dp"
          android:id="@+id/lay_write_comment"&gt;
  
          &lt;EditText 
              android:layout_width="0dp"
              android:layout_weight="8"
              android:hint="@string/str_your_commnet"
              android:layout_height="match_parent"
              android:padding="5dp"
              android:id="@+id/txt_comment"
              android:background="#ffffff"/&gt;
  
          &lt;ImageButton 
              android:layout_width="0dp"
              android:layout_weight="2"
              android:layout_height="wrap_content"
              android:background="@drawable/bg_button_login"
              android:src="@drawable/ic_menu_send"
              android:contentDescription="@string/str_post_comment"
              android:layout_marginLeft="5dp"
              android:id="@+id/btn_post_comment"/&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout 
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/lay_loading"
          android:background="@color/background_app"
          android:orientation="horizontal"
          android:gravity="center"&gt;
  
          &lt;ProgressBar 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              style="?android:attr/progressBarStyleSmall"/&gt;
  
          &lt;TextView 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/str_load_comment"
              android:layout_marginLeft="5dp"
              android:textSize="12sp"/&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>