Thanks to everyone, Timmmm was very helpful.
I've finally wrapped everything up and got a full soft-keyboard hiding solution for tab swiping.
I have 4 tabs with editTexts on each one and I need to hide keyboard when swiping.
I've added this to the fragment layout:
<!--Fixes keboard pop-up-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:focusable="true"
android:focusableInTouchMode="true">
</LinearLayout>
This was added to the Activity Code (notice a little difference with a Timmmm's answer: I don't have
mViewPager.getCurrentItem() == 0
here, because I need to hide the keyboard for every view:
// When swiping between different sections, select the corresponding
// tab. We can also use ActionBar.Tab#select() to do this if we have
// a reference to the Tab.
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
if (actionBar != null) {
actionBar.setSelectedNavigationItem(position);
}
}
@Override
public void onPageScrollStateChanged(int state) {
if (state == ViewPager.SCROLL_STATE_IDLE) {
// Hide the keyboard.
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(mViewPager.getWindowToken(), 0);
}
}
});
And here is an activity in AndroidManifest.xml:
<activity
android:name=".TestActivity"
android:label="@string/title_activity_test"
android:parentActivityName=".MainActivity"
android:windowSoftInputMode="stateHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.atrinax.test.MainActivity" />
</activity>