EditText automatically opens soft keyboard when Fragment is visible with ViewPager
<p>I have a <code>Fragment</code> (the compatibility version) with an <code>EditText</code> in its layout. I'm using a <code>ViewFlipper</code> to flip between fragments. When I get to this particular <code>Fragment</code>, the soft keyboard opens up automatically. This is not what I want. Here is what I've tried to stop it or hide it.</p>

<p>Tried: </p>

<pre><code>android:descendantFocusability="beforeDescendants" 
</code></pre>

<p>on the fragment's main view</p>

<p>Tried: </p>

<pre><code>android:windowSoftInputMode="stateHidden"
</code></pre>

<p>and </p>

<pre><code>android:windowSoftInputMode="stateAlwaysHidden"
</code></pre>

<p>in the manifest for the activity</p>

<p>Tried:</p>

<pre><code>InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mViewPager.getChildAt(position).getWindowToken(), 0);
</code></pre>

<p>on the OnPageChangeListener of my ViewPager</p>

<p>Tried:</p>

<pre><code>InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(voucherView.findViewById(R.id.redeem_mobile_number).getWindowToken(), 0);
</code></pre>

<p>in onCreateView in my Fragment</p>

<p>Tried:</p>

<pre><code>InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getView().findViewById(R.id.redeem_mobile_number).getWindowToken(), 0);
</code></pre>

<p>in onStart in my Fragment</p>

<p>Tried:</p>

<pre><code>voucherView.findViewById(R.id.redeem_mobile_number).clearFocus();
</code></pre>

<p>in onCreateView in my Fragment</p>

<p>It seems to me like onPageChangeListener is the place to do this because the other calls happen before the soft keyboard is actually open. Any help would be great.</p>
